2 Replies - 3199 Views - Last Post: 15 March 2015 - 03:34 PM

#1 streek405  Icon User is offline

  • D.I.C Addict

Reputation: 15
  • View blog
  • Posts: 721
  • Joined: 10-March 13

Scheme: let* bad syntax (missing body)

Posted 15 March 2015 - 02:52 PM

I am getting the above error for this and I dont know why

 (let*
       ([current car(p)]
        [next car(cdr(p))]))


Here is the code in its entirety:
(define sortP 
  (lambda (p sortedList);sortedList starts out empty
    (let*
       ([current car(p)]
        [next car(cdr(p))]))
    (cond
      ((= (length p) 0) sortedList);empty list 
      ;find the smallest power and add it to sortedList
      ((equal? (findSmallest (current next)) current) 
        sortP(combine(findSmallest (current cdr(next))) sortedList)
      )
      (else 
       sortP(combine(findSmallest (next cdr(next))) sortedList)
      ) 
    )
  )
)


I have tried including the entire cond statement within let*, but I still get the same error.

Is This A Good Question/Topic? 0
  • +

Replies To: Scheme: let* bad syntax (missing body)

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2517
  • View blog
  • Posts: 4,001
  • Joined: 21-June 11

Re: Scheme: let* bad syntax (missing body)

Posted 15 March 2015 - 03:13 PM

View Poststreek405, on 15 March 2015 - 10:52 PM, said:

I am getting the above error for this and I dont know why

 (let*
       ([current car(p)]
        [next car(cdr(p))]))


A let* expression has the form (let* bindings body), where bindings is a list of variable-expression pairs and body is an expression (whose value the let* expression will evaluate to). What you wrote has the form (let bindings), so as the error message points out, you're missing the body.

Also note that the function call syntax in Scheme is (function arguments), not function(arguments), so your calls to car and cdr are wrong.

Quote

I have tried including the entire cond statement within let*, but I still get the same error.


Can you show the code where you've done that? Maybe you got the nesting of the parentheses wrong (easy mistake to make in Scheme and Lisps in general), as that should have fixed the error.
Was This Post Helpful? 2
  • +
  • -

#3 streek405  Icon User is offline

  • D.I.C Addict

Reputation: 15
  • View blog
  • Posts: 721
  • Joined: 10-March 13

Re: Scheme: let* bad syntax (missing body)

Posted 15 March 2015 - 03:34 PM

View Postsepp2k, on 15 March 2015 - 03:13 PM, said:

A let* expression has the form (let* bindings body), where bindings is a list of variable-expression pairs and body is an expression (whose value the let* expression will evaluate to). What you wrote has the form (let bindings), so as the error message points out, you're missing the body.

Also note that the function call syntax in Scheme is (function arguments), not function(arguments), so your calls to car and cdr are wrong.


Thank you! That fixed all of the errors that I stated! :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1