In FunctionalJava.List, what does "snoc" mean?
Asked Answered
N

2

11

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

Noshow answered 6/10, 2011 at 12:32 Comment(0)
M
7

The name snoc is cons backwards.

Hope this helps.

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

Maidenhead answered 6/10, 2011 at 12:35 Comment(0)
A
20

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

cons originates from Lisp, I think.

Acceptor answered 6/10, 2011 at 12:34 Comment(2)
is "cons" an acronym for something?Noshow
Yes, the list primitive operators in the original Lisp were called car, cdr and cons. I believe that cons was short for "construct" - see en.wikipedia.org/wiki/ConsMingy
M
7

The name snoc is cons backwards.

Hope this helps.

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

Maidenhead answered 6/10, 2011 at 12:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.