Artifact 83796aed2eb89c0fc97d166b497187d1299dd83f643930e49ff2b7c4e94d36d7:
- Executable file
r37/lisp/csl/html/r37_0043.html
— part of check-in
[f2fda60abd]
at
2011-09-02 18:13:33
on branch master
— Some historical releases purely for archival purposes
git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/trunk/historical@1375 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1416) [annotate] [blame] [check-ins using] [more...]
<A NAME=CONS> <TITLE>CONS</TITLE></A> <b><a href=r37_idx.html>INDEX</a></b><p><p> <B>CONS</B> _ _ _ _ _ _ _ _ _ _ _ _ <B>operator</B><P> <P> The <em>cons</em> operator adds a new element to the beginning of a <A HREF=r37_0302.html>list</A>. Its operation is identical to the symbol <A HREF=r37_0023.html>dot</A> (dot). It can be used infix or prefix. <P> <P> <P> <H3> syntax: </H3> <em>cons</em>(<item>,<list>) or <item> <em>cons</em> <list > <P> <P> <P> <item> can be any REDUCE scalar expression, including a list; <list> must be a list. <P> <P> <P> <H3> examples: </H3> <P><PRE><TT> liss := cons(a,{b}); {A,B} liss := c cons liss; {C,A,B} newliss := for each y in liss collect cons(y,list x); NEWLISS := {{C,X},{A,X},{B,X}} for each y in newliss sum (first y)*(second y); X*(A + B + C) </TT></PRE><P>If you want to use <em>cons</em> to put together two elements into a new list, you must make the second one into a list with curly brackets or the <em>list </em> command. You can also start with an empty list created by <em>{}</em>. <P> <P> The <em>cons</em> operator is right associative: <em>a cons b cons c</em> is val id if <em>c</em> is a list; <em>b</em> need not be a list. The list produced is <em>{a,b,c}</em>. <P> <P> <P> <P>