Jump to content

Try to add seed as an option in this function


Recommended Posts

 

I try to put a seed as an option in this function with a default value of nil or no seed , how may i add it as optional 

 

Thanks  Patrick  

 

(defun patkaos ( seed lambda long )
 (let ((res (cons seed nil)) (xn seed))
    (dotimes (n long res) (setf res (cons (setf xn (* lambda xn (- 1 xn))) res)))
    (reverse res)))

Link to comment
Share on other sites

i looked at it and i tried to put it in the function , but without success 

 

This is what i did 

 

(defun patkaos (  lambda long &key seed  )

(rnd-seed seed )
 (let ((res (cons seed nil)) (xn seed))
    (dotimes (n long res) (setf res (cons (setf xn (* lambda xn (- 1 xn))) res)))
    (reverse res)))

 

when i evaluate this is what i gat 

 

Error: floating-point-overflow detected
>        performing * on (-2.5452163E+36 2.5452163E+36)
> While executing: ccl::*-2, in process Listener-1(7).
> Type cmd-. to abort, cmd-\ for a list of available restarts.
> Type :? for other options.

 

 

Thanks Patrick

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy