Search found 133 matches
- Wed May 14, 2014 6:13 pm
- Forum: Common Lisp
- Topic: Nested Lambda Expressions and Such...
- Replies: 4
- Views: 11280
Re: Nested Lambda Expressions and Such...
So a lambda expression is just the source expression of a function.. ((lambda (x y) (+ x y)) 5 2) ; ==> 7 When evaluated they are functions and functions can be passed in parameters and returned. A lambda expression which evaluates to the result of a lambda expression returns a function. You may cho...
- Mon Apr 21, 2014 1:44 pm
- Forum: Scheme
- Topic: Little help about define procedure
- Replies: 3
- Views: 34988
Re: Little help about define procedure
sqrt is defined by the package so you are not using your own version when doing the first sqrt . add is not included so you get an error. You can tell by just type inn identifiers in the interactions window before you define them and like sqrt you'll see #<procedure:sqrt> with sqrt replaced by some...
- Sat Mar 22, 2014 5:50 pm
- Forum: Common Lisp
- Topic: Function won't recurse?!!
- Replies: 4
- Views: 8467
Re: Function won't recurse?!!
A tail recursive solution (but it still needs help with TCO from the implementation not to blow the stack) Since all the structure is made within the function it's safe to do du destructive reverse. (defun dotted-list (lst) (labels ((aux (lst i acc) (if lst (aux (cdr lst) (1+ i) (cons (cons (car lst...
- Tue Feb 11, 2014 5:59 pm
- Forum: The Lounge
- Topic: Creating CONS cells in more primative languages.
- Replies: 2
- Views: 10331
Re: Creating CONS cells in more primative languages.
I think it's cool. Everyone should implement LISP in LISP and a non LISP language. A cons cell is just a object with two pointers, car and cdr. Both car and cdr can be any data type, but if you chain cons cells and the last cdr is NIL we call it a proper list and display it differently. You usually...
- Thu Nov 28, 2013 4:17 pm
- Forum: Homework
- Topic: basic, but I don't understand
- Replies: 1
- Views: 7735
Re: basic, but I don't understand
This is a double post. I've answered this thread!
- Thu Nov 28, 2013 4:13 pm
- Forum: Common Lisp
- Topic: Unbound variables
- Replies: 1
- Views: 5828
Re: Unbound variables
Hi there I think I answered your first problem already so I'll jump to your doLoop function: or this: (defun doLoop (do ((x 0 (+ x 2)) (y 0 (- y 2))) ((= x 2048) (print 'done)) (print x) (print y))) Like I said, when I try to run these are anything like them, I am getting an error message saying tha...
- Thu Nov 28, 2013 4:07 pm
- Forum: Homework
- Topic: just a basic for beginner.
- Replies: 1
- Views: 8948
Re: just a basic for beginner.
You use *defun* and that implies Common Lisp. Common Lisp is a LISP2 and it has separate namespace for everything in operator position and argument/variable position. To be able to use a function returned from a function or passed as argument you need to use *funcall* (defun main() (funcall (op 0) 3...
- Thu Nov 28, 2013 3:58 pm
- Forum: Homework
- Topic: Unbound variable problem
- Replies: 1
- Views: 8429
Re: Unbound variable problem
So quoting works like everything you put ' in front of becomes the literal thing you're seeing.. What it means is that it WONT be seen as a variable and lisp won't try to turn it into it's value, which it got from either being a parameter or a variable. Here is how to translate a line of code into a...
- Thu Nov 21, 2013 4:02 pm
- Forum: The Lounge
- Topic: Original Lisp Eliza added to Eliza Gen collection
- Replies: 3
- Views: 20153
Re: Original Lisp Eliza added to Eliza Gen collection
(DEFINEQ (RPLQQ (NLAMBDA RPLQ (RPLACD (CAR RPLQ) (CDR RPLQ))))) ; can't really tell if it's car or cdr but car would make a loop Based on this sniplet and Kent Pitman's paper on special forms I guess it's programmed in Interlisp. I'm not too familiar with it but I tink this NLAMBDA is just for auto...
- Sun Nov 10, 2013 1:27 pm
- Forum: Common Lisp
- Topic: In lisp which is faster a defun or a defmacro
- Replies: 6
- Views: 18740
Re: In lisp which is faster a defun or a defmacro
In some circumstances where there would be differences between defmacro and defun , defmacro would be the fastest (since you could constant fold). However, the best practice is to make it a function as long as it's possible to do what you want with functions. The 3 language agnostic rules of optimiz...