Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: The Mathematica equivalent of Cons (as in Lisp)?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73906] Re: [mg73849] The Mathematica equivalent of Cons (as in Lisp)?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 3 Mar 2007 00:54:28 -0500 (EST)

On 2 Mar 2007, at 13:50, Andrzej Kozlowski wrote:

>
> On 2 Mar 2007, at 12:25, wooks wrote:
>
>> For the benefit of someone with a Scheme background.
>>
>> Would it be Prepend. Are there any pitfalls to be wary of?
>>
>>
>
> Mathematica is quite different from Lisp and in particular  
> Mathematica's Lists are quite different from Lisp lists,  which are  
> rather like Mathematica's "linked lists" of the form {a,{b,....}}.  
> Tghus there is really nothing in Mathemaitca that corresponds to cons.
> You can try to immitate Lisp programming style in Mathematica but  
> your programs will be very inefficient. You cna of course write  
> your own implementation of Lisp in Mathematica. One obvious way is  
> to use cons as the Head of a lispList and define  car, cdr etc, as  
> follows:
>
> lispList[a_, b___] := cons[a, lispList[b]]
> car[cons[a_, b_]] := a
> cdr[cons[a_, b_]] := b
>
> etc.
>
> However, it is much simpler and far more  efficient to simply learn  
> Mathematica's one programming language.
>
> Andrzej Kozlowski
>
>

It is, of course, incorrect to say that there is nothing  
in Mathematica that corresponds to Cons.
In fact, from the definitions above, it is clear that the Mathematica  
"equivalent" of Cons is simply List.

Andrzej Kozlowski




  • Prev by Date: Re: The Mathematica equivalent of Cons (as in Lisp)?
  • Next by Date: Re: Integrals involving square roots
  • Previous by thread: Re: The Mathematica equivalent of Cons (as in Lisp)?
  • Next by thread: Parse results from Solve