Today there's a link on Hacker News to an interesting article by Steve Yegge (http://steve.yegge.googlepages.com/lisp-wins). In the article he compares two solutions to a simple problem, one written in Perl, the other in Java. I was wondering what the solution would look like in Arc: (= squares (map [* _ _] (range 1 5)))
(prall squares "" " ")
(prn)
This is the most pedantic solution to Steve's criteria. Since I was bored at work I started playing around with it by adding a couple utilities: (def prsp (xs)
(prall xs "" " ")
(prn))
(def sqr (x) (* x x))
prsp and sqr solve common enough problems that its possible to imagine them being included in arc's standard library.Leaving aside the creation of a variable we now have: (prsp:map sqr (range 1 5))
The range expression is pretty verbose compared to other languages such as Ruby and Haskell. What if an integer in functional position created a range? I wasn't sure how to hack ar-apply in ac.scm to get that to work.Any ideas? With that the final solution would be: (prsp:map sqr (1 5))
|