Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

scheme help pls

Name: Anonymous 2009-05-23 12:23

hey /prog/, I'm trying to do something simple and failing hard. I seem to be missing something obvious, but I'm not sure what. Using DrScheme here.

Suppose I have a list that represents infix notation, e.g.,
(1 + 2)
and I want to evaluate it. I can create a list that is in prefix notation assuming a simple list in this form:
(define infix->prefix (lambda (x)
                          (list (cadr x)
                                         (car x)
                                         (caddr x))))

And then
> (infix->prefix '(2 + 3))
(list '+ 2 3)
>

But, er, how would I evaluate this? That is, what am I missing so that
> (infix->prefix '(2 + 3))
5
>


Thanks for any insight.

Name: Anonymous 2009-05-23 12:46

>>3
apply: expects type <procedure> as 1st argument
fail. Nice bbcode tho.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List