Help with a lisp program

Discussion of Common Lisp

Re: Help with a lisp program

Postby wvxvw » Thu Oct 06, 2011 12:21 am

Oh, so using minimum function was allowed? Then you could just
Code: Select all
(apply 'min '(1 -13 42 0.005)) ; -13
I thought the task was to do the same thing w/o using it.
wvxvw
 
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am

Re: Help with a lisp program

Postby smithzv » Thu Oct 06, 2011 11:12 am

It's funny that you mentioned REDUCE before, but chose to not use it here, since it is technically the correct thing to do whereas APPLY might fail on a hypothetical, severely limited Lisp (perhaps for embedded systems?) when the list longer than 50.

Also, I think the task was to do the same thing without out. Note he said "minimum" function, not MIN function. He called the function he was writing "minimum".

Edit: of, this is directed to wvxvw
smithzv
 
Posts: 94
Joined: Wed Jul 23, 2008 11:36 am

Re: Help with a lisp program

Postby wvxvw » Fri Oct 07, 2011 1:27 am

I think the OP is doing some sort of homework, so it's not really important that the code accounts for all sorts of technical limitations. Ideally, there shouldn't be a limit on how long list of arguments a function can take. I think different Lisp implementations may differ in this regard as well. And, I assumed that the minimum function was the min - I think, I've at least a 50% chance of guessing that right :)
Besides reduce the OP could also use any kind of loop, or call min recursively using some improvised Y-combinator function etc. I didn't really mean that the last example is the only right, rather an alternative way to solve the problem. Although, yeah, if, for whatever reason I really needed that kind of functionality, I'd stick with reduce.
wvxvw
 
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am

Previous

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 1 guest

cron