Jump to content

LISP!

Coursework help! :P

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

LISP! Coursework help! :P Rate Topic: -----

#1 User is offline   Ineke 

  • Shortcut Freak
  • Group: Members
  • Posts: 493
  • Joined: 04-August 06
  • Gender:Female
  • Location:Romsey!

Post icon  Posted 28 November 2007 - 04:08 PM

I'm currently meant to be implementing the Lambda Calculus in the functional programming language, LISP

I will probably have lost most people in the above sentence, but for anyone that just knows LISP i just need help with some stupid brackets that are appearing where they shouldnt be!

this is my current code
(defun variable? (term) (if (eq (car term) 'VAR) t (if (eq (car term) 'var) t ())))
(defun abstraction? (term) (if (eq (car term) 'LAMBDA) t (if (eq (car term) 'lambda) t ())))
(defun application? (term) (if (eq (car term) 'APP) t (if (eq (car term) 'app) t ())))

(defun var-symbol (term) (if (variable? term) (cdr term) ()))
(defun make-var (term) (cons 'VAR (list term)))

(defun abs-var (term) (if (abstraction? term) (cadr term) ()))
(defun abs-body (term) (if (abstraction? term) (cddr term) ()))
(defun make-abs (term1 term2) (cons 'LAMBDA (cons term1 (list term2))))

(defun app-fn (term) (if (application? term) (car term) ()))
(defun app-arg (term) (if (application? term) (cdr term) ()))
(defun make-app (term1 term2) (cons 'APP (cons term1 (list term2))))


and we've been told that typing in
(make-abs 'x (make-app (make-var 'x) (make-var 'x)))

should return
(LAMBDA x (APP (VAR x) (VAR x)))

which it does! but then we were told that applying abs-body to it should return
(APP (VAR x) (VAR x))

but i get
((APP (VAR x) (VAR x)))


any ideas?!
Do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of it's own.
PS: Here's my website!
0

#2 User is offline   Man2u2uk 

  • W.R. Lieutenant
  • Group: Members
  • Posts: 396
  • Joined: 14-April 07
  • Gender:Male

Posted 28 November 2007 - 04:14 PM

Damn that confused me :blink:
0

#3 User is offline   Ineke 

  • Shortcut Freak
  • Group: Members
  • Posts: 493
  • Joined: 04-August 06
  • Gender:Female
  • Location:Romsey!

Posted 28 November 2007 - 04:20 PM

it has aparantly been joked that LISP stands for "let's insert some parentheses" ...they're not wrong!
I don't know what it actually stands for!
Do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of it's own.
PS: Here's my website!
0

#4 User is offline   Catalyst 

  • Codesmith
  • Group: Administrators
  • Posts: 1,049
  • Joined: 04-April 06
  • Gender:Male
  • Location:San Diego

Posted 28 November 2007 - 06:06 PM

I don't know LISP and while I'd usually drift off to learn some at this point I've got too much work :(

So all I can suggest is that you might try this free IDE for LISP that I found via Google http://student.agh.e...ualclisp/en.htm

It might at least help with syntax errors, like missing brackets
0

#5 User is offline   Telos 

  • Eternal Being
  • Group: Members
  • Posts: 250
  • Joined: 08-May 07
  • Gender:Male
  • Location:Finland

Posted 29 November 2007 - 01:55 AM

Hmm... I'm imagining 2000 lines of that and how clear it looks then :) Sorry I can't help you with your problem, don't know nothing about LISP.
I am a man without a website
0

#6 User is offline   Karl Buckland 

  • A.K.A. Sirkent
  • Group: Administrators
  • Posts: 2,145
  • Joined: 04-April 06
  • Gender:Male
  • Location:Kent, UK

Posted 29 November 2007 - 05:20 AM

I'm sorry that I don't know any lisp... or actually I'm not because it looks a bit nasty.

Can you lay out each statement on multiple lines, or does lisp insist on having each statement on it's own line? Laying out the statements on multiple lines might take up more room but it'll be easier to read, and with indentation with the parenthesis you'll be able to see where you've missed one more easily?

I had similiar hell at Uni with Haskell and Prolog, so I can sympathise. At least Lisp is (I think) more well known than those, so you might be able to find some help on the net.
QUOTE(benbramz @ Aug 17 2007, 07:44 AM) Ive noticed that quite a few people are now adding quotes from the board into their signature. I think its started an new web-radiance craze.. :P
0

#7 User is offline   benbacardi 

  • Administrator
  • Group: Administrators
  • Posts: 1,140
  • Joined: 06-April 06
  • Gender:Male
  • Location:United Kingdom

Posted 29 November 2007 - 06:18 AM

View PostSirkent, on Nov 29 2007, 10:20 AM, said:

I had similiar hell at Uni with Haskell and Prolog


<hijack>I used to like Prolog!</hijack>
0

#8 User is offline   Ineke 

  • Shortcut Freak
  • Group: Members
  • Posts: 493
  • Joined: 04-August 06
  • Gender:Female
  • Location:Romsey!

Posted 30 November 2007 - 06:28 AM

i got up the courage to ask my lecturer, who has managed to fix that little glitch, however i have a lot more of the program to write :(
is there anyone who knows lisp here, as in if i have any other issues is there any point me posting here or not? :P
Do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of it's own.
PS: Here's my website!
0

#9 User is offline   Ben Abrams 

  • The buddy system:never fails
  • Group: Administrators
  • Posts: 1,850
  • Joined: 04-April 06
  • Gender:Male

Posted 30 November 2007 - 11:31 AM

View PostIneke, on Nov 30 2007, 11:28 AM, said:

i got up the courage to ask my lecturer, who has managed to fix that little glitch, however i have a lot more of the program to write :(
is there anyone who knows lisp here, as in if i have any other issues is there any point me posting here or not? :P

want to post the answer and answer the thread?

View PostSirkent, on 21 September 2007 - 04:26 AM, said:

<monty python high-pitched female voice>I DON'T LIKE SPAM!</monty python high-pitched female voice>
0

#10 User is offline   Ineke 

  • Shortcut Freak
  • Group: Members
  • Posts: 493
  • Joined: 04-August 06
  • Gender:Female
  • Location:Romsey!

Posted 03 December 2007 - 10:29 AM

yea why not, basicaly, in the line with the abs-body it needs to be caddr not cddr near the end as this prevents it from being returned as a list! :)
Do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of it's own.
PS: Here's my website!
0

#11 User is offline   EncoderDecoder 

  • W.R. Sergeant
  • Group: Members
  • Posts: 260
  • Joined: 01-March 11
  • Gender:Female
  • Location:Philippines

Posted 29 May 2011 - 08:22 AM

what's lisp..? this is my first time hearing about this.. :confused1:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users