geting the median of 3 values using sheme car & cdr

Posted by kristian Roger on Stack Overflow See other posts from Stack Overflow or by kristian Roger
Published on 2010-04-30T23:10:37Z Indexed on 2010/04/30 23:17 UTC
Read the original article Hit count: 279

Filed under:

Hi still stuck with the ugly scheme

the problem this time is to get the median of three values (easy)

I did all these :

(define (med x y z) (car(cdr(x y z)))

and it was accepted but when testing it

(med 3 4 5)

I will get this error

Error: attempt to call a non-procedure (2 3 4)


and when entering letters inetead of number i got

(md x y z)

Error: undefined varia
       y
       (package user)

using somthin else than x y z i got

(md d l m)

Error: undefined variable
       d
       (package user)

so what is wronge ?!

© Stack Overflow or respective owner

Related posts about Scheme