[racket] TLS "atom?" definition for Scheme does not work in DrRacket
Use BSL with List Abbreviation.
On Mar 3, 2015, at 3:50 PM, Rufus <rlaggren at mail.com> wrote:
> Alexander
>
> Well, in fact, I thought it worked for me, too. And then it stopped
> working; DrR threw an "application: not a procedure;" error saying it
> was given a null list instead of an application. Removing the parens got
> it working again.
>
> Now that just doesn't make any sense at all but that's what I seem to
> have observed. Looking at some StackOverflow responses on similar errors
> I found that parens in certain positions are interpreted as invoking a
> function regardless of what may in fact be inside the parens. IOW, extra
> parens will trigger that error. I believe that initially it was working.
> Perhaps I had run it in the executable pane instead of loading and
> running the defs file? If I have more time somewhere along, I'll try to
> recreate things.
>
> When I first defined atom? I was using a very small definitions file
> with the " #lang racket" spec; IIRC atom? worked. After trying BSL and
> then going back to using the #lang spec and adding some comments and the
> list of variable defs - it didn't work.
>
> At the moment I don't have any good ideas, except to chg the code to get
> it to work and proceed.
>
> Rufus
>
>
>
> On 03/03/2015 02:21 PM, Alexander D. Knauth wrote:
>> This works for me:
>> (define atom? (lambda (arg1)
>> (and (not (pair? arg1))
>> (not (null? arg1)))))
>>
>>
>> On Mar 3, 2015, at 3:16 PM, Rufus <rlaggren at mail.com> wrote:
>>
>>> On page 10 of TLS there is a note defining the "atom?" function for the
>>> reader to use w/Lisp or Scheme. The definition for Scheme (which is the
>>> most likely one to use for DrR) does not work. To fix one must remove
>>> the parens that open at the "and". Apparently the DrR
>>> compiler/interpreter sees them as an attempt to invoke a function and
>>> that's not correct here. I don't know if other Lisp versions would find
>>> the code in the book correct.
>>>
>>> In the text below XXX shows where I removed a set of parens to make the
>>> function work.
>>>
>>> (define atom? (lambda (arg1)
>>> XXX and (not (pair? arg1))
>>> (not (null? arg1))
>>> XXX
>>> )
>>> )
>>>
>>>
>>> Rufus
>>> ____________________
>>> Racket Users list:
>>> http://lists.racket-lang.org/users
>>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users