|
|||||||
| Programming, Coding, (Web)Design Discuss all your programming or design needs with likeminded people. |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
DriverHeaven Extreme Member
Join Date: Jun 2004
Location: Floatin'...
Posts: 4,957
Rep Power: 0 ![]()
|
Is anyone here good at LISP? I got some homework due next tues and i haven't started it as yet mainly because i have absolutely no idea what to do. i am currently reading the lecture notes and i am completely lost. so can anyone help with my hw, please? not asking for someone to do it for me (althought that would be appreciated
), but some help will do, if possible. Thanks... link to hw assignment: http://www.csee.umbc.edu/331/fall04/homework/hw9/ |
|
|
|
|
|
#2 |
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
ewww 'Lost In Senseless Parenthesis'
![]() if it isn't due for a while I can have ms. Vandevenne look at it monday, as she knows LISP |
|
|
|
|
|
|
|
|
DriverHeaven Extreme Member
Join Date: Jun 2004
Location: Floatin'...
Posts: 4,957
Rep Power: 0 ![]()
|
Quote:
before that would be great, John. Thanks for helping...
|
|
|
|
|
|
|
#4 |
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
haha....can't help you then....as I won't see her until monday the 29th at 2pm and am busy all day monday
|
|
|
|
|
|
|
|
|
DriverHeaven Extreme Member
Join Date: Jun 2004
Location: Floatin'...
Posts: 4,957
Rep Power: 0 ![]()
|
Quote:
|
|
|
|
|
|
|
#6 |
|
Delete Me
Join Date: Mar 2004
Posts: 14,648
Rep Power: 0 ![]() ![]() ![]() ![]() ![]() ![]() |
you want her email?
|
|
|
|
|
|
#7 |
|
Anti-Piracy Poster Boy
|
1. Look at the definition and usage of cons and list. You need to construct the lists in the first column using only cons for the second column and only list for the third column.
(a b c) for instance is (cons (cons (cons 'a nil) b) c) and (list 'a 'b 'c) 2. Look at the definition and usage of car and cdr. car returns the first element in a list and cdr returns the rest of the list. Play around in lisp with expressions like (car (list 'a 'b 'c)) and (cdr (list 'a 'b 'c)). Everything else should be pretty standard assuming you already know how to program in some other language. It takes time to get used to programming and thinking in lisp, but you're only conquering a syntax hurdle.
__________________
"It is because the resistance to paying for copyrighted material, although often characterized as arising from a supposed technical burden or principled concern for the public interest, arises rather from exactly the same segment of the brain that is dominant in shoplifters." - Mark Helprin, Digital Barbarism In other words, it's never okay to steal even if you think you have a good reason! www.yayitsandrew.com
|
|
|
|
|
|
|
|
DriverHeaven Extreme Member
Join Date: Jun 2004
Location: Floatin'...
Posts: 4,957
Rep Power: 0 ![]()
|
thanks for the help, andrew. it seems to figure out #1 and #2 is by trial and error. try different expressions until i get it right. must be a better way of figuring out these things. anyways i managed to figure out the first 2 rows of #1 by pure luck. one answer troubles me though, it's for (a b c). for the cons i put :[color=white] (cons ‘a ‘(b c) ). is this a possible answer or is the answer u provided the only one? thanks again, andrew...
[/color]
|
|
|
|
|
|
#9 |
|
Anti-Piracy Poster Boy
|
The instructions for number 1 dictate that you aren't allowed to use a quoted list.
__________________
"It is because the resistance to paying for copyrighted material, although often characterized as arising from a supposed technical burden or principled concern for the public interest, arises rather from exactly the same segment of the brain that is dominant in shoplifters." - Mark Helprin, Digital Barbarism In other words, it's never okay to steal even if you think you have a good reason! www.yayitsandrew.com
|
|
|
|
|
|
|
|
DriverHeaven Extreme Member
Join Date: Jun 2004
Location: Floatin'...
Posts: 4,957
Rep Power: 0 ![]()
|
ok. btw, i checked and ur suggestion for (a b c) for the cons was wrong. it's (cons 'a (cons 'b (cons 'c nil))).
|
|
|
|
|
|
#11 |
|
Anti-Piracy Poster Boy
|
Sorry looks like I forgot the single quots before b and c, so it thought they were variable names. Try what I had before but with 'b and 'c. If it still doesn't work, then there's something special about cons in lisp that I don't know about and doesn't exist in scheme.
I really know scheme and not lisp, but they're pretty similar.
__________________
"It is because the resistance to paying for copyrighted material, although often characterized as arising from a supposed technical burden or principled concern for the public interest, arises rather from exactly the same segment of the brain that is dominant in shoplifters." - Mark Helprin, Digital Barbarism In other words, it's never okay to steal even if you think you have a good reason! www.yayitsandrew.com
|
|
|
|
|
|
#12 |
|
Anti-Piracy Poster Boy
|
as per your IM:
nil is an empty list. () cons joins an element with a list. (cons element list). This may be why mine didn't work before I was doing (cons list element). Anyway, (cons 'a nil) will be the element 'a added to the nil list. You get (a). (cons 'a (cons 'b nil)) is tricky. Work inside out just like in algebra. First (cons 'b nil) is (b). now we have (cons 'a (b)) which is (a b). If we wanted to get mor confused we could do (cons (cons 'a nil) (cons 'b nil)). That breaks to (cons (a) (b)) and should give the list ((a) b). I think you need (cons (cons 'a nil) (cons (cons 'b nil) nil)) to get ((a) (b)). Play around with it. list is a little different, you specify all the elements of the list in the declaration. (list element1 element2 element3 ...). So (list a b c) is (a b c) and (list (list a) (list b)) is (list (a) (b)) is ((a) (b)). When working in Lisp you need to be able to get your bearings straight when surrounded by parenthesis. Think of the algebraic equation (4 + (2 * (4 + 7 + (2 - 6) * (2 + 4)))). You'd solve that the same way you go about working in lisp. From the inside out.
__________________
"It is because the resistance to paying for copyrighted material, although often characterized as arising from a supposed technical burden or principled concern for the public interest, arises rather from exactly the same segment of the brain that is dominant in shoplifters." - Mark Helprin, Digital Barbarism In other words, it's never okay to steal even if you think you have a good reason! www.yayitsandrew.com
|
|
|
|
![]() |
| Thread Tools | |
|
|