|
|
|
|
|
by Y_Y
635 days ago
|
|
In SICM they frequently make use of a kind of implicit applicative lifting (I can't remember what they call it) where you apply a vector-of-functions as if it were a function itself. In psuedo-Haskell: lift :: Vec (a->b) -> (a->Vec b)
lift [] a = []
lift f:fs = (f a):(lift fs $ a)
so that you can write natural-looking multidimensional physics expressions like ((fx fy fz) r)
without having to invoke macros or restructure the expression to please the compiler. I dearly wish you could do this in another scheme but so far I haven't found one. Iirc it's required for using the magnificent `scmutils` package too.For example, `guile-scmutils`[0] says: > Functionality not available in the port: > Scheme extension to allow applying vectors/structures as procedures. For example rather than 1 ]=> (pe ((up (literal-function 'x) (literal-function 'y)) 't))
(up (x t) (y t))
> you must use guile> (pe ((lambda (t) (up ((literal-function 'x) t) ((literal-function 'y) t))) 't))
(up (x t) (y t))
[0] https://www.cs.rochester.edu/~gildea/guile-scmutils/ |
|