4 ms·
Your example is a bit apples-to-oranges, in a few ways. First your examples are using different constructs, as well as different languages. It's perfectly reas
by chriswarbo 6y ago
Your example is a bit apples-to-oranges, in a few ways.
First your examples are using different constructs, as well as different languages. It's perfectly reasonable and "lispy" to write a for loop like your first example, e.g. (this is pretty much the same as the first example in https://docs.racket-lang.org/reference/for.html https://docs.racket-lang.org/reference/for.html )
(for ((i '(1 2 3)))
(x i)
(y i)
(z i))
Likewise Lisps don't have a monopoly on factoring common functionality out into helper functions like 'map', e.g. a C-like equivalent to your second example is not at all unusual:
map(
seq(x, y, z),
range(3))
(I've replaced the symbolic name '->' with a made up non-symbolic name 'seq', to do the same job of applying multiple functions to an argument).
Secondly you bring up "off-side rule" indentation, like Python, without mentioning I-expressions or their equivalents. These can be used by all Lisps (and anything else based on s-expressions, like DSSSL, since they're trivially convertable to/from s-expressions. Some Lisps also have native support (e.g. they're standardised in Scheme https://srfi.schemers.org/srfi-49/srfi-49.html https://srfi.schemers.org/srfi-49/srfi-49.html ).
> map/reduce/recur/let/etc are special
I agree for 'let', and it already is a "special form" in most Lisps. I disagree for 'map' and 'reduce', since they are ordinary function calls that are not special in any way (that's part of the appeal for functional programming and macros: that we're not stuck with a finite number of first-order "control structures"). I've not encountered "recur" before, I assume it's a Clojure workaround for JVM tail-call deficiencies? A quick Google shows that it's also a "special form", like 'let'.