New version of makelist



Brief example:

(defmspec $minimakelist (x)
  (let ((f (second x))
	(x (third x))
	(lo (meval (fourth x)))
	(hi (meval (fifth x)))
	(l nil))
    (setq f `((lambda) ((mlist) ,x) ,f))
    (while (<= lo hi)
      (push (mfuncall f lo) l)
      (incf lo))
    (simplifya (cons '(mlist) (reverse l)) t)))

I think it's OK to call simplifya with a second argument of t, but I'm not sure.
A few examples:

 (%i68) minimakelist(if x = 6 then 1 else 0,x,0,9);
 (%o68) [0,0,0,0,0,0,1,0,0,0]

 (%i69) minimakelist(integrate(x^k,x),k,-1,3);
 (%o69) [log(x),x,x^2/2,x^3/3,x^4/4]

 (%i70) showtime : all$
  Evaluation took 0.0000 seconds (0.0000 elapsed)

An unfair test (minimakelist lacks features and error checking)

 (%i71) minimakelist(if x = 6 then 1 else 0,x,0,99999)$
  Evaluation took 1.0200 seconds (1.0200 elapsed)

 (%i72) makelist(if x = 6 then 1 else 0,x,0,99999)$
  Evaluation took 1.5200 seconds (1.5200 elapsed)

Barton

-----Jaime Villate <villate at fe.up.pt> wrote: -----

>To:?Barton?Willis?<willisb at unk.edu>
>From:?Jaime?Villate?<villate at fe.up.pt>
>Date:?04/24/2010?01:15PM
>cc:?Maxima?<maxima at math.utexas.edu>
>Subject:?Re:?[Maxima]?New?version?of?makelist
>
>On?Sat,?2010-04-24?at?12:23?-0500,?Barton?Willis?wrote:
>>?Great.?Maybe?it's?not?worthwhile,?but?you?might?consider?rewriting
>>?$makelist?to?eliminate?the?call?to?$ev.
>You're?right;?I'll?do?that.?I'm?too?used?to?ev,?but?I?agree?with?the
>messages?that?have?appeared?in?this?list?discouraging?its?use.
>
>>?You?could?either?model?the?code?after?$create_list,?or?you?could?build
>>?a?Maxima?lambda?form?and?do?mfuncall?on?the?Maxima?lambda?form.?I
>>?think?the?Maxima?lambda?form?is?easier?to?document.
>The?Maxima?lambda?form?sounds?interesting;?could?you?please?elaborate
>more?on?that?point??perhaps?give?me?a?brief?example?
>
>Regards,
>Jaime