[racket] first vs car ; last vs cdr ; empty? vs null?

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Fri Mar 7 23:03:57 EST 2014

The first/rest operations do not use a memoization table.  They test using
the list? primitive, which is built in and actually has a couple of tag
bits reserved on every cons object for memoizing its results.  So the
operation really is quite fast.

Carl Eastlund

On Fri, Mar 7, 2014 at 4:40 PM, Eric Dong <yd2dong at uwaterloo.ca> wrote:

> So if code is using first/rest instead of car/cdr when I already know the
> lists are proper, it could incur a significant performance penalty? After
> all, memoization still needs a table lookup each time I do a first/rest.
>
> (i.e. implementing datastructures in terms of lists should use car/cdr for
> performance right? any benchmarks?)
>
>
> On Friday, March 7, 2014, Sean Kanaley <skanaley at gmail.com> wrote:
>
>> Pardon me, but going back a bit where the blog about switching to
>> immutable lists was mentioned...I saw an interesting comment about
>> immutability and eq?.  Have any mathematicians come up with an answer for
>> the meaning of eq? on permanently distinct but equivalent and immutable
>> objects, e.g. (eq? (cons 3 2) (cons 3 2))?  What about on immutable objects
>> that have mutable internal state, e.g. memoizing functions?
>> Naive-but-memoized (fib 1000) is not necessarily the same as (fib 1000),
>> unless the answer doesn't depend on the number of universes that have
>> bigbanged meanwhile.
>>
>>
>>
>> On Fri, Mar 7, 2014 at 2:31 PM, Daniel Carrera <dcarrera at gmail.com>wrote:
>>
>>> Thanks.
>>>
>>>
>>> On 7 March 2014 20:22, Harry Spier <vasishtha.spier at gmail.com> wrote:
>>>
>>>> See also this previous thread on the Racket list.
>>>>  http://www.mail-archive.com/users%40racket-lang.org/msg12161.html
>>>>
>>>>
>>>>
>>>>
>>>> ____________________
>>>>   Racket Users list:
>>>>   http://lists.racket-lang.org/users
>>>>
>>>>
>>>
>>>
>>> --
>>> When an engineer says that something can't be done, it's a code phrase
>>> that means it's not fun to do.
>>>
>>> ____________________
>>>   Racket Users list:
>>>   http://lists.racket-lang.org/users
>>>
>>>
>>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140307/1dddbb4c/attachment.html>

Posted on the users mailing list.