Search found 10 matches

by yesimthetaxman
Mon Jul 25, 2011 9:19 am
Forum: Common Lisp
Topic: is it possible to write a strict AND function?
Replies: 17
Views: 14558

Re: is it possible to write a strict AND function?

ohh ya your right i didn't realize that lol
by yesimthetaxman
Sun Jul 24, 2011 5:06 pm
Forum: Common Lisp
Topic: is it possible to write a strict AND function?
Replies: 17
Views: 14558

Re: is it possible to write a strict AND function?

turns out that the answer is actually quite simple:

(defun and-nl (a b) (and a b))

since arguments are evaluated before they are passed to the routine body we have an AND that forces the evaluation of both arguments to AND.
by yesimthetaxman
Tue Jul 12, 2011 10:55 pm
Forum: Common Lisp
Topic: is there a way to replace the elements in a list?
Replies: 7
Views: 11587

is there a way to replace the elements in a list?

I don't actually mean destructively replace, I mean lets say you pass the list (a b c d e), I want to return the list (8 8 8 8 8)... so basically I want a list returned with the same number of elements but instead of the original items, it'd be an item of my choosing. I am able to do this using the ...
by yesimthetaxman
Tue Jul 12, 2011 1:01 am
Forum: Common Lisp
Topic: What does clisp do behind the scene if you give it (* 2 2 2)
Replies: 10
Views: 10431

Re: What does clisp do behind the scene if you give it (* 2 2 2)

If (* 2 2 2) is somehow converted to (* (* 2 2) 2), then that extra step used in the conversion would mean that technically it would take slightly longer for the CPU to compute right? In SBCL, it actually does take a single extra operation to do (* a (* b c)) as compared to (* a b c). I'd assume CL...
by yesimthetaxman
Mon Jul 11, 2011 11:08 pm
Forum: Common Lisp
Topic: What does clisp do behind the scene if you give it (* 2 2 2)
Replies: 10
Views: 10431

Re: What does clisp do behind the scene if you give it (* 2 2 2)

well actually the reason I am wondering is not because I am worried about efficiency, its more of an argument. I lost marks on an assignment (an entire letter grade) because "there is a simpler solution"... The question said: "compute 2^3"... Anyways, I am arguing that his defini...
by yesimthetaxman
Mon Jul 11, 2011 9:38 pm
Forum: Common Lisp
Topic: What does clisp do behind the scene if you give it (* 2 2 2)
Replies: 10
Views: 10431

Re: What does clisp do behind the scene if you give it (* 2 2 2)

just to add, I realize that operators like * are n-ary operators... but I am wondering specifically which one is "faster", or more efficient, aside from the argument that one is "easier to read" then the other...
by yesimthetaxman
Mon Jul 11, 2011 9:29 pm
Forum: Common Lisp
Topic: What does clisp do behind the scene if you give it (* 2 2 2)
Replies: 10
Views: 10431

What does clisp do behind the scene if you give it (* 2 2 2)

you can write (* (* 2 2) 2) or you can write (* 2 2 2)... I am wondering what is happening behind the scenes when comparing the two. If (* 2 2 2) is somehow converted to (* (* 2 2) 2), then that extra step used in the conversion would mean that technically it would take slightly longer for the CPU t...
by yesimthetaxman
Mon Jul 11, 2011 9:38 am
Forum: Common Lisp
Topic: is it possible to write a strict AND function?
Replies: 17
Views: 14558

Re: is it possible to write a strict AND function?

wow there are so many ideas, thank you. I think the problem with this question is that it is suppose to avoid higher order functions that do the work for you... apparently there is an elegant solution that uses only basic functions, no macros. once I figure it out I will post it here. I don't think ...
by yesimthetaxman
Thu Jul 07, 2011 7:22 pm
Forum: Common Lisp
Topic: is it possible to write a strict AND function?
Replies: 17
Views: 14558

is it possible to write a strict AND function?

I am trying to write a simple boolean AND function that uses eager/strict evaluation. That is, I want both arguments to the AND function to be evaluated. I am able to write a function to simulate this using IF statements, but it is long, I am wondering if anyone has any ideas how to write a shorter,...