Arc Forumnew | comments | leaders | submit | jc's commentslogin
1 point by jc 6097 days ago | link | parent | on: Cut and Index - Arc and Ruby Side By Side

I second this. It seems easier to ape Python's syntax for slicing. For example, given s as "abcde,"

  s[1:4]
  (s 1 4)
gives "bcd,"

  s[1:-2]
  (s 1 (- 2))
gives "bc,"

  s[-4:]
  (s (- 4) nil)
gives "bcde," and

  s[:]
  (s nil nil)
gives "abcde."

-----

1 point by jc 6097 days ago | link | parent | on: Cut and Index - Arc and Ruby Side By Side

I think there's a reccuring mistake in the arc snippet for "The items from position i to the end minus the last j items."

I think it should be

  (cut s i -j)
... but I know I could be missing something

(thanks for the help, cadaver)

-----

1 point by cadaver 6097 days ago | link

Have a look at the little "help" next to the "about" box in your profile.

Also, I noticed that some people use a single ' to quote a function name on its own within a sentence (just like in Arc).

-----


This suggestion may be a bit un-Arc, but I'd prefer a "with-infix" macro implementing a well-defined sub-language than I would some kind of integration into the reader. An optional precedence list arg might be a good idea.

The problem there is, of course, that the s-exprs generated by the macro are essentially a black box, but in my thinking, if infix is being used minimally and purely for convenience's sake, it isn't necessary to make those s-exprs accessible to other macros (right?...).

-----