Forum: Rants
Topic: How come when you're writing Lisp, everything thing pisses you off?
started by: aventari

Posted by aventari on Apr. 22 2001,02:04
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?


Posted by Rhydant on Apr. 22 2001,03:00
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


Posted by CatKnight on Apr. 22 2001,04:45
some schools have classes on how to direct/star in pornographic films.
Posted by DuSTman on Apr. 22 2001,08:52
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!)


Posted by aventari on Apr. 25 2001,02:46
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.


Posted by askheaves on Apr. 25 2001,02:51
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.


Posted by ASCIIMan on Apr. 25 2001,06:03
<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


Posted by Jynx on Apr. 25 2001,18:34
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.


Powered by Ikonboard 3.1.4 © 2006 Ikonboard