02:05
aw- has joined #picolisp
03:45
orivej has joined #picolisp
03:54
mtsd has joined #picolisp
04:01
orivej has quit [Ping timeout: 268 seconds]
04:18
razzy has joined #picolisp
05:41
razzy has quit [Quit: Connection closed]
06:34
theruran has quit [Ping timeout: 245 seconds]
06:36
theruran has joined #picolisp
07:01
orivej has joined #picolisp
07:08
orivej has quit [Ping timeout: 252 seconds]
10:04
beneroth has joined #picolisp
10:16
untakenstupidnic has joined #picolisp
10:17
<
untakenstupidnic >
anyone online?
10:17
<
Regenaxer >
hi untakenstupidnic!
10:17
<
untakenstupidnic >
hi Regenaxer
10:18
<
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)
10:18
<
Regenaxer >
'let' has different syntax
10:19
<
Regenaxer >
(de fact (X) (let I 1 (let Ret 1 (while ...
10:19
<
Regenaxer >
(de fact (X) (let (I 1 Ret 1) (while ...
10:20
<
Regenaxer >
Also note the upper case variable names
10:20
<
Regenaxer >
just a convention though, but has reasons
10:21
<
Regenaxer >
I would write:
10:21
<
Regenaxer >
(de fact (X) (let Ret 1 (for I X (setq Ret (* Ret I)))))
10:22
<
beneroth >
welcome untakenstupidnic
10:22
<
untakenstupidnic >
beneroth, tnx
10:24
<
beneroth >
when a (let) expression is left, then all variable bindings in the let are reset to the previous values of those variables
10:24
<
beneroth >
default value for variables is always everywhere NIL
10:25
<
untakenstupidnic >
how do you "return" stuff?
10:26
<
Regenaxer >
Each expression has a value
10:26
<
Regenaxer >
so the result of the last exqression is returned
10:26
<
Regenaxer >
The way you returned 'ret' is ok too
10:26
<
Regenaxer >
(de fact (X) (let Ret 1 (for I X (setq Ret (* Ret I))) Ret))
10:26
<
Regenaxer >
but not needed here
10:27
<
Regenaxer >
cause the last 'setq' does it already
10:27
<
Regenaxer >
So the main issue was 'let'
10:28
<
Regenaxer >
(let Variable <initialValue> ... body ...)
10:28
<
untakenstupidnic >
I entered (fact 100000) and it ended without returning anything
10:29
<
Regenaxer >
In my version above?
10:29
<
untakenstupidnic >
yes
10:29
<
Regenaxer >
: (de fact (X) (let Ret 1 (for I X (setq Ret (*
10:29
<
Regenaxer >
-> fact
10:29
<
Regenaxer >
Ret I)))))
10:29
<
Regenaxer >
: (fact 10000)
10:29
<
Regenaxer >
-> 28462596809170545....
10:30
<
untakenstupidnic >
: (de fact (X) (let Ret 1 (for I X (setq Ret (* Ret I)))))
10:30
<
untakenstupidnic >
: (fact 8)
10:30
<
untakenstupidnic >
-> 40320
10:30
<
untakenstupidnic >
-> fact
10:30
<
untakenstupidnic >
: (fact 10000000)
10:30
<
untakenstupidnic >
^C(setq Ret (* Ret I))
10:30
<
untakenstupidnic >
! (fact 100000)
10:30
<
untakenstupidnic >
->
10:31
<
untakenstupidnic >
it has 5 zeroes
10:32
<
Regenaxer >
Hundred thousand gives a very big number. Needs quite some memory I suspect
10:32
<
Regenaxer >
But worked here
10:32
<
Regenaxer >
took a while
10:33
<
untakenstupidnic >
you entered ten thousand in what you pasted here
10:33
<
Regenaxer >
yes, but then hundred
10:33
<
Regenaxer >
here on my phone, with Termux:
10:33
<
Regenaxer >
: (bench (fact 100000) T)
10:33
<
Regenaxer >
23.400 sec
10:34
<
Regenaxer >
Faster on a real machine probably
10:34
<
untakenstupidnic >
oh it just printed it now.
10:34
<
Regenaxer >
(I put a 'T' to suppress printing the result
10:35
<
Regenaxer >
yeah, printing takes longer than the calculation perhaps
10:35
<
Regenaxer >
it must be converted to decimal
11:35
orivej has joined #picolisp
13:24
orivej has quit [Ping timeout: 260 seconds]
13:40
olaf_h has joined #picolisp
14:39
<
untakenstupidnic >
how do you do float math. (/ 1.0 2.0) gives 0
14:41
<
Regenaxer >
PicoLisp has only integers, so you must use fixpoint
14:41
orivej has joined #picolisp
14:41
<
Regenaxer >
(scl 6)
14:41
<
Regenaxer >
(*/ 1.0 1.0 2.0)
14:45
<
Regenaxer >
You can use any scale
15:06
<
olaf_h >
link copied, thank you
15:15
aw- has quit [Quit: Leaving.]
15:34
<
beneroth >
hey olaf_h :)
15:55
<
untakenstupidnic >
Regenaxer: it says scl is undefined
16:00
<
beneroth >
what is returned by (version)
16:01
<
beneroth >
untakenstupidnic, did you maybe do (let scl ...) or (setq scl) somewhere?
16:02
<
beneroth >
or did you start picolisp binary instead of using pil startscript?
16:02
<
beneroth >
scl is defined in lib.l, must be present
16:03
aw- has joined #picolisp
16:11
<
Regenaxer >
Hi olaf_h!
16:12
<
Regenaxer >
Hmm, it looks like untakenstupidnic started raw bare metal bin/picolisp then
16:12
<
Regenaxer >
untakenstupidnic: The normal start command is
16:12
<
Regenaxer >
$ pil +
16:12
<
Regenaxer >
or $ ./pil +
16:12
<
Regenaxer >
depends
16:13
<
Regenaxer >
Did you try $ man picolisp ?
16:14
<
beneroth >
most likely
16:29
anddam has quit [Quit: WeeChat 3.1]
16:29
<
olaf_h >
hi beneroth :) sorry, did not see you in time. i dont know how config a bell in HexChat when my name appears
16:29
<
olaf_h >
.... my nick is mentioned
16:30
<
beneroth >
hmm...good question. cannot remember I ever had to configure it, but possible
16:30
<
beneroth >
no worries
16:32
<
beneroth >
olaf_h, you should check out tankf33der's repo.. he translated incredibly many algorithms and exercises into picolisp. very educational and useful examples
16:36
<
olaf_h >
thank you, you mean the link he just posted, right? Because 'tankf33der (Mike)' repo on github isn't that clear to me
16:37
<
beneroth >
ah I see...
16:38
<
beneroth >
tankf33der, ?
16:38
<
beneroth >
I guess I should not save the links but clone your repos
16:41
<
olaf_h >
okay, that repo url copied, too - but looks like it expects more experienced readers - the fixedpoint link above is better for me :-)
16:46
anddam has joined #picolisp
17:09
untakenstupidnic has quit [Remote host closed the connection]
17:15
olaf_h has quit [Quit: Leaving]
20:42
mtsd has quit [Ping timeout: 240 seconds]
23:36
orivej has quit [Ping timeout: 265 seconds]