Arc Forumnew | comments | leaders | submitlogin
5 points by mattjones 6126 days ago | link | parent

The . and ! syntax is really handy.

I noticed chaining doesn't work for .:

    arc> (= l '(1 2 (3 4) 5))
    (1 2 (3 4) 5)
    arc> l.2
    (3 4)
    arc> l.2.1
    (3 4)
rather than 4. Another thought ... could ranges be expressed a la Ruby?

    arc> (= l '(1 2 3 4 5))
    (1 2 3 4 5)
    arc> l.1..4
    (2 3 4 5)


5 points by sjs 6126 days ago | link

Multiple dots pass multiple params to the initial function. To chain you have to group w/ parens.

  arc> (= l '(1 2 (3 4) 5))
  (1 2 (3 4) 5)
  arc> l.2.1
  (3 4)
  arc> (l.2 1)
  4
That 2nd last one translates to (l 2 1), which as you found acts like (l 2).

-----

3 points by mattjones 6126 days ago | link

Yep, thanks. It would be cool if there were an abbreviation for that, since it's fairly common. Eg l.2%1 (% randomly chosen) => ((l 2) 1). Some may say that goes too far toward a parentheses alternative for all sorts of things, but on the other hand data structure access is one of the clumsier parts of Lisp.

The present semantics of . make sense though.

-----

2 points by andreyf 6126 days ago | link

Maybe 'l' is not the best letter for that variable?

-----