10

FunctionJava's List class has a snoc method that does append: snoc

The description is as follows:

Appends (snoc) the given element to this list to produce a new list.

What does the word "snoc" here mean? I have tried to look it up in Wikipedia and as an acronym with no success. Does this mean it is doing some special kind of append?

Edit: Thanks all for pointing me to cons

John B
  • 32,493
  • 6
  • 77
  • 98

2 Answers2

18

It's "cons" reversed as cons prepends, snoc appends.

cons originates from Lisp, I think.

egaga
  • 21,042
  • 10
  • 46
  • 60
  • is "cons" an acronym for something? – John B Oct 06 '11 at 12:39
  • 2
    Yes, the list primitive operators in the original Lisp were called `car`, `cdr` and `cons`. I believe that `cons` was short for "construct" - see http://en.wikipedia.org/wiki/Cons – Stephen C Oct 06 '11 at 12:40
5

The name snoc is cons backwards.

Hope this helps.

http://jlambda.com/~iop/GraphicsActor2D/doc/g2d/jlambda/List.html

Sean Chapman
  • 322
  • 1
  • 10