https://github.com/wting/hackernews
This is a great place to start with understanding Arc, as the jump to Anarki (an Arc fork) will make more sense as it comes bundled with News - a Hacker News style app - which is fun to play with if you have experience with HN and want to try a variation of this site.
arc> (= l '(1 2 3))
(1 2 3)
arc> (= f [+ _ 1])
#<fn: f>
arc> (map l '(0 1 2))
(1 2 3)
arc> (map f '(0 1 2))
(1 2 3)For the benefit of people familiar with Common Lisp:
* (= ...) is assignment, not equality testing
* (map list index-list) is equivalent to (loop for index in index-list collecting (nth index list)), or in a more FP style (mapcar (rcurry #'nth list) index-list)
* (map function list) is equivalent to (mapcar function list)
I think your example would have been less confusing if it used larger numbers to highlight where addition was happening and where indexing was happening: arc> (= l '(4 5 6))
(4 5 6)
arc> (= f [+ _ 10])
#<fn: f>
arc> (map l '(2 1 0 0))
(6 5 4 4)
arc> (map f '(0 1 2))
(10 11 12) 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? 1
and l
in the same code listing.Wouldn't it be better to separate CSS and JS into separate, static files and only have the forum deal with, at best, IDs and classes in HTML?
I'm asking because I'm tempted to actually try to fork it and make a PR for it but it seems like such a simple and obvious bit of housekeeping that I have to assume there's a reason no one else has bothered yet.
[0]https://github.com/arclanguage/anarki/blob/master/lib/news.a...
Interesting to see what this will lead to.
(I've used Clojure and JS, which also seems like a "Lisp"-1 in that you can just put fns into variables and call them like 1st class fns, I just don't get why the distinction is in any way positive rather than confusing, and in Lisp-2s you now need to dereference everything all the time, like in Ruby).