Re: JESS: Calling a function on all elements in a list

2008-03-10 Thread Wolfgang Laun
Why do you want to avoid foreach which happens to cater for your needs? Just write a simple wrapper (I'll call it apply$) and use it just like (apply): ; a function to be called on each element of a list (deffunction show (?x) (printout t show: ?x crlf) ) ; (apply$ function expression*) ;

Re: JESS: Calling a function on all elements in a list

2008-03-10 Thread Ernest Friedman-Hill
Actually, something much like Wolfgang's apply$ is already built into recent versions of Jess; it's called map. But I actually don't think that's what the O.P. is after: rather than calling a function with each element of a list as successive arguments, I think he wants to call the function on

JESS: Calling a function on all elements in a list

2008-03-08 Thread JKBM
I was wondering if there was any way to call a function on a variable containing a list without having to use a foreach/while loop. (apply + 1 2 3) obviously works, but (apply + (create$ 1 2 3)) doesn't, so that doesn't help me. This sort of problem comes up a lot, and I usually handle it by