This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Best program to use lisp on?

18 posts · 18358 views

Hi im new to using lisp and need to do some assignments, unfortunately ive not got any software on my computer to do so, Im wondering whats the most user friendly software that i could use. As a beginner ive got some pretty complex code to try get my head around, so any links would be greatly appreciated.
Thanks.
Im glad to see a lisp forum, good job.

Re: Best program to use lisp on?

You want a compiler/interpeter right?
I suppose it depends what you want:
the personal edition of lispworks (free, but with limited heap space and 5 hr time limit, among other things) is very easy to use. http://www.lispworks.com/downloads/ In reality, all the 5 hr time limit means is that you have to exit lispworks and then re-load your program, and the time limit resets. So, no big deal.

Another easy one (as in there are binaries available for win32), if you don't mind not having a graphical interface, is clisp. http://clisp.cons.org/

I personally prefer sbcl over lispworks, mainly for the reason that it can use the package :arnesi (code walker), while lispworks can't. HOwever, it's not exactly 'easy to get into, atleast for win32, because you have to compile it yourself. Now, if you know how to compile programs, i guess its no big deal.

Oh, and if you want to use libraries defined by others, the asdf package is a must (it consists of only 1 file). Since i knew i had trouble at first using asdf, just post if you want some handy code that'll make using asdf a breeze (well, atleast on win32. i guess ic ould expand the same to other platforms.)

Edit: oh, and on lispworks, i haven't yet found a way to open multiple lisp files on the personal edition. maybe i'm missing something.
Edit: lol, i just checked, and there is a way. hmm, too hasty

Re: Best program to use lisp on?

Harnon wrote: I personally prefer sbcl over lispworks, mainly for the reason that it can use the package :arnesi (code walker), while lispworks can't. HOwever, it's not exactly 'easy to get into, atleast for win32, because you have to compile it yourself. Now, if you know how to compile programs, i guess its no big deal.
The SBCL website has a link to the binary for 1.0.13 on windows. But there is that "Your Kitten of Death awaits!" thing, which means you can/will get unreproducible GC variant lost, exception access violations, etc. at random points in time.
Edit: oh, and on lispworks, i haven't yet found a way to open multiple lisp files on the personal edition. maybe i'm missing something.
Just use File->Open, the Open button, or C-x C-f. The editor is Emacs based so your files are in different buffers; take a look under the buffers tab, or use C-x b

Anyways, I like the LispWorks Personal Edition for use in windows, though I might also use CLISP or SBCL depending on what I'm doing.

Under GNU/Linux, I have CLISP, but I develop with SBCL+SLIME.

Re: Best program to use lisp on?

Thanks alot guys, i downloaded lispworks
It was the same one i used in college, i just couldnt remember the name of it. Well i must try get some work done now
I'll most likely post here if i need help with code. Can i do that?

Re: Best program to use lisp on?

Brew wrote:I'll most likely post here if i need help with code. Can i do that?
You bet. That's why LispForum exists.

Personally, I use Emacs/SLIME+SBCL on Linux and Emacs/SLIME+CLISP on Windows. I'm looking forward to the day that SBCL on Windows stabilizes enough to use it all the time there, too. I have nothing bad to say about CLISP. It's a really good implementation with a strong set of standard libraries. For general programming work, I simply prefer SBCL.
Cheers, Dave
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/

Re: Best program to use lisp on?

Ok thats great to know thanks a million :D , Thats like a lifesaver to know.
I'll post the following up, perhaps it'll mean more to you guys. Infact im sure it's simple stuff which really could be done in a few lines of code.

For one section anyway , I must write a lisp function "price-order-total" which takes a list representing an order in the form ((item1 quantity1 unit-price1)(item2 quantity2 unit-price2) ... ) and then it returns a total price for the complete order.
Has anyone any experience doing this type of thing, im sure its pretty darn basic but im under some serious pressure with alot of stuff, anything would be GREATLY appreciated.
Thanks in advance.

Re: Best program to use lisp on?

a great learning utility for lisp is http://gigamonkeys.com/book/, practical common lisp.
once you're a little more advanced, i would suggest reading the free book on lisp (Free download)
http://www.paulgraham.com/onlisptext.html

Try
(defun price-order-total (item-list)
(loop for item in item-list
summing (* (second item) (third item))))

or, a little neater
(defun price-order-total (item-list)
(loop for item in item-list
summing (destructuring-bind (item quantity unit-price) item (* quantity unit-price))))
though theres really no use for destructuring bind, the first one is faster

Take a look at 'loop for black belts' in practical common lisp
Just wondering, what is this work for?

Re: Best program to use lisp on?

Harnon wrote: Just wondering, what is this work for?
Well a while back i had some problems at home and unfortunately this is course work which ive to make up over the summer. Ive got pages of it and i was looking into it the past few days with no progression what so ever. So i took a break, reassessed things and thought i'd check online to see if there was something out there that could give me a push start in the right direction. So i really appreciate you helping out there harnon. I hate being a sponge when it comes to askin for help with code. Thanks again.
I had looked at a pdf file with info of paul grahams notes and found it a little clustered, perhaps needing something a bit more basit so That gigamonkeys.com link you sent me was just what i needed, i didnt think there were free tutorials online for this sort of thing, Again, thanks Harnon.

Re: Best program to use lisp on?

Harnon wrote: or, a little neater
(defun price-order-total (item-list)
(loop for item in item-list
summing (destructuring-bind (item quantity unit-price) item (* quantity unit-price))))
Or even neater:
(defun price-order-total (item-list)
  (loop for (item quantity price) in item-list
        sum (* quantity price)))

Re: Best program to use lisp on?

Lol, i forgot for a second that the loop macro had a built in destructuring bind. :roll:

Re: Best program to use lisp on?

Brew wrote:Hi im new to using lisp and need to do some assignments, unfortunately ive not got any software on my computer to do so, Im wondering whats the most user friendly software that i could use. As a beginner ive got some pretty complex code to try get my head around, so any links would be greatly appreciated.
As mentioned earlier, you have Lispworks and CLISP for Windows, as well as SBCL (with the caveat that it may not be stable). There is also Allegro CL with an IDE for Lisp in Windows, but I find that Lispworks is a little more user-friendly, especially for beginners. One benefit of Allegro is that it doesn't have a time limit, although it still has a heap limit, but you'll probably never hit that if you're writing small programs.

Re: Best program to use lisp on?

My survey paper at http://common-lisp.net/~dlw/LispSurvey.html describes all eleven currently-maintained Common Lisp implementations, and has lots and lots of pointers to textbooks, papers, resources, and so on.

Last edited by dlweinreb on , edited 1 time in total.

Re: Best program to use lisp on?

Or, for a more functional approach, there's:
(defun price-order-total (item-list)
(apply #'+ (mapcar #'third item-list)))

Re: Best program to use lisp on?

Perhaps this might the more accurate functional version?
(defun price-order-total (item-list)
  (apply #'+ 
	 (mapcar #'(lambda(item)
		     (destructuring-bind (i quantity unit-price) item
		       (declare (ignore i))
		       (* unit-price quantity)))
		 item-list)))

Re: Best program to use lisp on?

reuben.cornel wrote:
(defun price-order-total (item-list)
  (apply #'+ 
	 (mapcar #'(lambda(item)
		     (destructuring-bind (i quantity unit-price) item
		       (declare (ignore i))
		       (* unit-price quantity)))
		 item-list)))
Oh, come on! You functional types surely can do better than that.
(defun price-order-total (item-list)
  (reduce #'+ (mapcar #'*
                      (mapcar #'second item-list)
                      (mapcar #'third item-list))))
Now to transform this into points-free style... Wait, this isn't #haskell? Damn, I knew there was something wrong with the colours.

Re: Best program to use lisp on?

thanks guys for the help, ive a problem though
I need to be able to add more function to the question.
for example im trying to figure out how to get this
LISP> (price-order-total '((bolts 7 2.99)(nuts 7 1.19)(screws 20 0.79))) 45.06

The above multiplys the order by the the price of each item, adding them along the way and returnin a total, in this case the totals 45.06


Ive got the code worked out im just wondering if anyone would be able to make it more neater for me?
i'll paste it here.
(setf boltprice 2.99)
(setf nutprice 1.19)
(setf screws .79)
  (setf boltquantity 7)
(setf nutquantity 7)
(setf screwquantity 20)
 (setf bolttotal ( * boltprice boltquantity))
(setf nuttotal ( * nutprice nutquantity))
(setf screwtotal (* screws screwquantity))
(setf total ( + screwtotal nuttotal bolttotal))
I hope im posting this right, the code i have eventually brings me the total number. but it seems like perhaps it could be summarised?


Thanks in advance.

Re: Best program to use lisp on?

You should use DEFVAR or DEFPARAMETER to create global variables rather than SETF. Use DEFVAR when you want subsequent re-evaluations to leave the current value alone, and DEFPARAMETER when you want them to take effect. In this case, you want DEFPARAMETER.

When you find yourself using variables to represent tables of data, it's time to introduce some sort of data structure, the advantage being that data structures can be iterated over when they contain items that can all be treated in the same way.
;; All orders will be created with this function, so I can change
;; the data structure I use for an order any time I like. I can add
;; optional and keyword parameters to it without disturbing the
;; legacy interface.
(defun order (item-name quantity item-price)
  (list item-name quantity item-price))

;; All legal operations on orders are defined here; if I change
;; the data structure I can simply update these functions
;; and legacy code will continue to work properly.
(defun name (order) (first order))
(defun quantity (order) (second order))
(defun price-per (order) (third order))
(defun subtotal (order) (* (quantity order) (price-per order)))

;; Since all orders have the same interface, I can simply iterate
;; when I want to deal with a lot of them.
(defun total-bill (bill)
  (loop for o in bill summing (subtotal o)))
Whenever you find yourself using a programming language as an excessively verbose calculator, it's time to take a step back and factor something out. In this case, I saw a whole bunch of orders, so I devised an interface of five functions to create and get data from orders, and used that interface along with some list operations (one of CL's built-in interfaces) to write TOTAL-BILL in a high-level way. When you get your interface right, you can program just by telling the computer what you want, viz. the total of a list of orders:
;; Altogether, I've written one more line of code than you did--but if
;; I want to add more items to a bill, I just tack them onto this list
;; (which would probably be generated programmatically or read from a
;; database anyway).
(total-bill (list (order 'bolts 7 2.99)
                  (order 'nuts 7 1.19)
                  (order 'screws 20 0.79)))
If I wanted to be obsessive, I could have defined a bill type as well, but since a list is a list, unlike an order which stores several different types of data (name, quantity, price), I didn't see the advantage. If you expected to be typing up a lot of bills by hand, a macro implementing a less verbose syntax than (list (order 'thing &c... would be nice to have. You could also use DEFSTRUCT or DEFCLASS to create your data types, or make the list-based order type official with DEFTYPE.

Re: Best program to use lisp on?

One more thing:

Your use of ten assignment statements in a row is also a red flag. There's nothing wrong with SETF per se, but when you're creating a variable to store every step of the equation, you often end up creating a variable that only gets used once—such as... every single one of them, in this case :)—and you can often simplify your code by taking advantage of the fact that every form returns a value: turning the code "inside out", you might say. To do so, just substitute in all variables that are referred to only once. When begin to write a function, I'm often not sure which calculations I'll need to access twice, so I go ahead and add a a bunch of variables to my LET as I go along, with the expectation that's most of these will get unwritten when I take a look at the whole thing.

In this particular program, inversion results in a chain of nameless arithmetic, due to the loss of names, which is a clue that you either need to factor out some patterns before you simplify, or else that there are no patterns and what you really wanted was a calculator.