Search Members Help

» Welcome Guest
[ Log In :: Register ]

 

[ Track This Topic :: Email This Topic :: Print this topic ]

reply to topic new topic new poll
Topic: How come when you're writing Lisp, everything thing pisses you off?< Next Oldest | Next Newest >
 Post Number: 1
aventari Search for posts by this member.
Jedi Knight
Avatar



Group: Members
Posts: 662
Joined: Dec. 2000
PostIcon Posted on: Apr. 22 2001,02:04  Skip to the next post in this topic. Ignore posts   QUOTE

I know I ganked your title Spydir, but I had to scream: EAT SHIT, YOU MOTHERFUCKERS (who designed lisp)!

Argh, I guess it's not really the language that im extra pissed at, its my CS professor. She expects us to learn lisp and write a fairly hard program in 1.5 weeks.

We have to write a program that recursively does change for an amount of coins or dollars entered. which isn't bad, but we have to do up to 10 combinations of change if available.
Which is pretty tough in a language that is nothing like C/C++ or Java or any imperitive languages.
Next week, Prolog is up..

So does anyone here know Lisp? I need to pick your brain for a bit

------------------
If corn oil comes from corn, where does baby oil come from?

Offline
Top of Page Profile Contact Info 
 Post Number: 2
Rhydant Search for posts by this member.
I don't work here.
Avatar



Group: Members
Posts: 1843
Joined: Dec. 2000
PostIcon Posted on: Apr. 22 2001,03:00 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

quote:
Originally posted by aventari:
...my CS professor...

what school do YOU go too? hell, any college that teaches you how to play counter-strike must be helluva cool. just duck when firing!
uhm... i dont know Lisp. i dont know any programming language. sorry man.

------------------
...when you look long into an abyss, the abyss also looks into you
-- Friedrich Nietzsche

Offline
Top of Page Profile Contact Info WEB 
 Post Number: 3
CatKnight Search for posts by this member.
Jedi Republican
Avatar



Group: Members
Posts: 3807
Joined: Dec. 2000
PostIcon Posted on: Apr. 22 2001,04:45 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

some schools have classes on how to direct/star in pornographic films.
Offline
Top of Page Profile Contact Info WEB 
 Post Number: 4
DuSTman Search for posts by this member.
70% water in a flexible container.
Avatar



Group: Members
Posts: 797
Joined: May 2000
PostIcon Posted on: Apr. 22 2001,08:52 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

Yeah, lisp has to be one of the most awkward syntaxes ever developed..

Thankfully i don't have to do it any more.. (i learnt it in 2 hours, did my coursework and forgot about the POS!)

Offline
Top of Page Profile Contact Info 
 Post Number: 5
aventari Search for posts by this member.
Jedi Knight
Avatar



Group: Members
Posts: 662
Joined: Dec. 2000
PostIcon Posted on: Apr. 25 2001,02:46 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

I'm damn glad to give this rant a swift painful death.

I finished my lisp program and turned it in today. I've already forgotten what it does

code:

;;change.lsp
;;aventari CS351 4-25-2001 3:47 AM

;;change() is a recursive function to give the best change for a given amount.
;; "best change" is defined as the smallest number of coins.
;; you pass in the amount to make change for, and a list of the denominations available
;; to make change out of.

(defun change(input list)
(cond
((eql nil list) nil)
((= input input) (cons (divide input (car list)) (change (mod input (car list)) (cdr list))))
)
)


;;main1() of course is the starting function, it sets the coin types, then prints messages to the user
;; main1 reads the user input and calls the correct functions to make the change. It has some error
;; handling ability as well if the user enters a bad numeric value

(defun main1()
(setf coins '(50 25 10 5 1))
(format t "~\%~\% This program will make change for you.~\% press 1 to enter a bill amount greater than one (no 2 dollar bills)~\% press 2 to enter a coin amount or 1 dollar~\% : ")
(setf x (read))
(cond
((= x 2) (format t "~\% input value of coinage to make change for (in cents, enter 100 for dollar bill) :") (setf x (read)) (format t "~\%Best change is on top~\%")(output(change x coins)) (variations x (change x coins) coins 0))
((= x 1) (format t "~\% input value of bill(s) to make change for (in dollars) :") (setf x (read)) (format t "~\%Best change is on top~\%") (output(change (* 100 x) coins)) (variations (* 100 x) (change (* 100 x) coins) coins 0))
((not (= x 2)) (format t "~\%~\% input error.. enter a 1 or 2") )
((not (= x 1)) (format t "~\%~\% input error.. enter a 1 or 2") )

)
)


;;variations() is my function that will make 9 different change combinations for a given total.
;; it takes a lot of arguments, the first is the total amount we are making change for, the
;; second is the "best change" list of coins, the 3rd is the list of coins we are making
;; use of, and the 4th is a counter so we will only make 9 more combinations. The counter steps
;; in increments of 5 because it is used in the calculation of different change.
;;The coins list in here is wierd because it is used to make the change function give all
;; pennys for a given input instead of the 'best change' which is usually does.

(defun variations(total input list counter)
(setq x (car(cdr(cdr(cdr(cdr input))))) )
(setq pennys (+ x (+ counter 1)) )
(setf coins '(1000 1000 1000 1000 1))
(cond
((<= counter 40)
(cond
((>= (- total pennys) 0) (output (addLists (change (- total pennys) list) (change (+ x (+ counter 1)) coins)) ) (variations total input list (+ counter 5)) )
((< (- total pennys) 0) nil)
)
)
)
)


;;output() is a simple function that outputs a list of coins to the user in a pretty format

(defun output (money)
(format t "~a 50('s), ~a quarter(s), ~a dime(s), ~a nickel(s), and ~a penny(s)~\%"
(car money) (car(cdr money)) (car(cdr(cdr money))) (car(cdr(cdr(cdr money)))) (car(cdr(cdr(cdr(cdr money)))))
)
)


;;recursive function that will add the individual elements of 2 lists together into 1 list

(defun addLists(list1 list2)
(cond
((atom list1) nil)
((atom list2) nil)
((= 1 1) (cons (+ (car list1) (car list2)) (addLists (cdr list1) (cdr list2)) ) )
)
)


;;recursive divide function that truncates remainder instead of giving fraction or floating point

(defun divide (in divis)
(if (< (- in divis) 0) 0
(+ (divide (- in divis) divis) 1)
)
)

;;the end!


thats for if you didn't believe DuSTman's syntax comment..

------------------
You are what you drive
----------------------
Acura NSX: I am impotent.

Offline
Top of Page Profile Contact Info 
 Post Number: 6
askheaves Search for posts by this member.
Ack!!!
Avatar



Group: Members
Posts: 1955
Joined: Sep. 2000
PostIcon Posted on: Apr. 25 2001,02:51 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

The only thing I glean from that pile of crap is that 'list' is a native type. Thank fucking god.

It's my firm belief that strings and most other containers should be a basic type. That's my only beef with C++. I hate manually converting BSTRs into useful things. Fucking wchar arrays and char arrays and crap. I just sit there and leak memory all over the rug.

Offline
Top of Page Profile Contact Info 
 Post Number: 7
ASCIIMan Search for posts by this member.
-- Insert Witty Title Here --
Avatar



Group: Members
Posts: 408
Joined: Sep. 2000
PostIcon Posted on: Apr. 25 2001,06:03 Skip to the previous post in this topic. Skip to the next post in this topic. Ignore posts   QUOTE

<Obi-Wan>
askheaves, uuusse the STL...
</Obi-Wan>

#include <string>

This message has been edited by ASCIIMan on April 26, 2001 at 08:03 PM

Offline
Top of Page Profile Contact Info 
 Post Number: 8
Jynx Search for posts by this member.
resident n0b0dy
Avatar



Group: Members
Posts: 333
Joined: Dec. 2000
PostIcon Posted on: Apr. 25 2001,18:34 Skip to the previous post in this topic.  Ignore posts   QUOTE

The new Lisp motto:

"If the parenthesis don't kill you, the recursion will."

FYI, you may think that you might use something from your Lisp class in later life, but most likely you won't.

Trust me.


------------------
--Jynx

I used to be a kleptomaniac, but then I took something for it.

Offline
Top of Page Profile Contact Info 
7 replies since Apr. 22 2001,02:04 < Next Oldest | Next Newest >

[ Track This Topic :: Email This Topic :: Print this topic ]


 
reply to topic new topic new poll

» Quick Reply How come when you're writing Lisp, everything thing pisses you off?
iB Code Buttons
You are posting as:

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code