4 ms·
I don't know Arc, so this confuses me: arc> (map l '(0 1 2)) (1 2 3) What is the logic here? Is l made into a function that holds state and returns each e
by sago 8y ago
I don't know Arc, so this confuses me:
arc> (map l '(0 1 2))
(1 2 3)
What is the logic here? Is l made into a function that holds state and returns each element in turn (like an iterator function)? Because I would've expected:
arc> (map l '(0 1 2))
((1 2 3) (1 2 3) (1 2 3))
In what way is map being applied here?
- sago 8y agoAfter RTFM, I can answer my own question: > In Arc, data structures can be used wherever functions are, and they behave as functions from indices to whatever's stored there. (quoted from the Arc tutorial) So arc> (l 0) 1 and so on. So the GP makes sense.
- dmead 8y agothat's confusing as hell. there's a reason this didn't take off (Besides the competition from clojure)
- quadcore 8y agoIt's kinda cool to be able to write (myarray i).
- etatoby 8y agoI don't like the Arc language because it's dynamically typed and thus inherently unsafe (see other threads for this sort of discussion.) But I like this particular feature. If you think about it, an array is a mathematical function, or map, from indices to values. So it makes sense to be able to apply it to indices to get the respective values.
- ScottBurson 8y agoI think the list '(0 1 2) is behaving like the function — in CL syntax, sorry, I don't know Arc — (lambda (x) (elt '(0 1 2) x)). That is, the list is being treated as a sequence, which is a function from each index to the corresponding element.
- jacobush 8y agoIs PicoLisp the same?