ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Check also http://www.picolisp.com for more information
aw- has joined #picolisp
orivej has joined #picolisp
mtsd has joined #picolisp
orivej has quit [Ping timeout: 268 seconds]
razzy has joined #picolisp
razzy has quit [Quit: Connection closed]
theruran has quit [Ping timeout: 245 seconds]
theruran has joined #picolisp
orivej has joined #picolisp
orivej has quit [Ping timeout: 252 seconds]
beneroth has joined #picolisp
untakenstupidnic has joined #picolisp
<untakenstupidnic> anyone online?
<Regenaxer> hi untakenstupidnic!
<untakenstupidnic> hi Regenaxer
<untakenstupidnic> what is the problem with this: (de fact (x) (let i 1) (let ret 1) (while (<= i x) (let ret (* i ret)) (let i (+ i 1))) ret)
<Regenaxer> 'let' has different syntax
<Regenaxer> (de fact (X) (let I 1 (let Ret 1 (while ...
<Regenaxer> or
<Regenaxer> (de fact (X) (let (I 1 Ret 1) (while ...
<Regenaxer> Also note the upper case variable names
<Regenaxer> just a convention though, but has reasons
<Regenaxer> I would write:
<Regenaxer> (de fact (X) (let Ret 1 (for I X (setq Ret (* Ret I)))))
<beneroth> welcome untakenstupidnic
<untakenstupidnic> beneroth, tnx
<beneroth> when a (let) expression is left, then all variable bindings in the let are reset to the previous values of those variables
<beneroth> default value for variables is always everywhere NIL
<untakenstupidnic> how do you "return" stuff?
<Regenaxer> Each expression has a value
<Regenaxer> so the result of the last exqression is returned
<Regenaxer> The way you returned 'ret' is ok too
<Regenaxer> (de fact (X) (let Ret 1 (for I X (setq Ret (* Ret I))) Ret))
<Regenaxer> but not needed here
<Regenaxer> cause the last 'setq' does it already
<Regenaxer> So the main issue was 'let'
<Regenaxer> (let Variable <initialValue> ... body ...)
<untakenstupidnic> I entered (fact 100000) and it ended without returning anything
<Regenaxer> In my version above?
<untakenstupidnic> yes
<Regenaxer> : (de fact (X) (let Ret 1 (for I X (setq Ret (*
<Regenaxer> -> fact
<Regenaxer> Ret I)))))
<Regenaxer> : (fact 10000)
<Regenaxer> -> 28462596809170545....
<untakenstupidnic> : (de fact (X) (let Ret 1 (for I X (setq Ret (* Ret I)))))
<untakenstupidnic> : (fact 8)
<untakenstupidnic> -> 40320
<untakenstupidnic> -> fact
<untakenstupidnic> : (fact 10000000)
<untakenstupidnic> ^C(setq Ret (* Ret I))
<untakenstupidnic> ! (fact 100000)
<untakenstupidnic> ->
<untakenstupidnic> it has 5 zeroes
<Regenaxer> Hundred thousand gives a very big number. Needs quite some memory I suspect
<Regenaxer> But worked here
<Regenaxer> took a while
<untakenstupidnic> you entered ten thousand in what you pasted here
<Regenaxer> yes, but then hundred
<Regenaxer> here on my phone, with Termux:
<Regenaxer> : (bench (fact 100000) T)
<Regenaxer> 23.400 sec
<Regenaxer> -> T
<Regenaxer> Faster on a real machine probably
<untakenstupidnic> oh it just printed it now.
<Regenaxer> (I put a 'T' to suppress printing the result
<Regenaxer> )
<Regenaxer> yeah, printing takes longer than the calculation perhaps
<Regenaxer> it must be converted to decimal
orivej has joined #picolisp
orivej has quit [Ping timeout: 260 seconds]
olaf_h has joined #picolisp
<untakenstupidnic> how do you do float math. (/ 1.0 2.0) gives 0
<Regenaxer> PicoLisp has only integers, so you must use fixpoint
orivej has joined #picolisp
<Regenaxer> (scl 6)
<Regenaxer> (*/ 1.0 1.0 2.0)
<Regenaxer> There is a good article on this: https://www.the-m6.net/blog/fixed-point-arithmetic-in-picolisp
<Regenaxer> You can use any scale
<olaf_h> link copied, thank you
aw- has quit [Quit: Leaving.]
<beneroth> hey olaf_h :)
<untakenstupidnic> Regenaxer: it says scl is undefined
<beneroth> what is returned by (version)
<beneroth> ?
<beneroth> untakenstupidnic, did you maybe do (let scl ...) or (setq scl) somewhere?
<beneroth> or did you start picolisp binary instead of using pil startscript?
<beneroth> scl is defined in lib.l, must be present
aw- has joined #picolisp
<Regenaxer> Hi olaf_h!
<Regenaxer> Hmm, it looks like untakenstupidnic started raw bare metal bin/picolisp then
<Regenaxer> untakenstupidnic: The normal start command is
<Regenaxer> $ pil +
<Regenaxer> or $ ./pil +
<Regenaxer> depends
<Regenaxer> Did you try $ man picolisp ?
<beneroth> most likely
anddam has quit [Quit: WeeChat 3.1]
<olaf_h> hi beneroth :) sorry, did not see you in time. i dont know how config a bell in HexChat when my name appears
<olaf_h> .... my nick is mentioned
<beneroth> hmm...good question. cannot remember I ever had to configure it, but possible
<beneroth> no worries
<beneroth> yay thx
<beneroth> olaf_h, you should check out tankf33der's repo.. he translated incredibly many algorithms and exercises into picolisp. very educational and useful examples
<Regenaxer> yeah
<olaf_h> thank you, you mean the link he just posted, right? Because 'tankf33der (Mike)' repo on github isn't that clear to me
<beneroth> ah I see...
<beneroth> I guess this one is the current main one https://git.envs.net/mpech/tankf33der
<beneroth> tankf33der, ?
<beneroth> I guess I should not save the links but clone your repos
<olaf_h> okay, that repo url copied, too - but looks like it expects more experienced readers - the fixedpoint link above is better for me :-)
anddam has joined #picolisp
untakenstupidnic has quit [Remote host closed the connection]
<olaf_h> bye
olaf_h has quit [Quit: Leaving]
mtsd has quit [Ping timeout: 240 seconds]
orivej has quit [Ping timeout: 265 seconds]