beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
<tankf33der> Searching for fast loop over 1:20M numbers. It is tricky, i need profiling for the first time ever.
<abu[m]> In memory? Or DB?
<tankf33der> Memory
<abu[m]> Can you give more info?
<abu[m]> Is it a list of numbers?
<tankf33der> Afk
<tankf33der> ret
<tankf33der> this code shows how for is faster
<abu[m]> Yeah, shorter is usually faster
<tankf33der> and if added simple chop call it becames slower
<tankf33der> if run in multi million loop
<abu[m]> Yes, 'chop' is a lot more expensgve
<abu[m]> it creates garbage etc
<tankf33der> if add (gc 64) it 20% faster
<tankf33der> so many details i should know.
<abu[m]> I also don't know what is best sometimes. Measuring like you do ist best
<tankf33der> yeah.
<abu[m]> Perhaps some native call in the core of the loop?
<abu[m]> must go, bbl
<tankf33der> solved task
<tankf33der> afk
clacke has joined #picolisp
_whitelogger has joined #picolisp
calle has joined #picolisp
calle has quit [Ping timeout: 264 seconds]
calle has joined #picolisp
calle has quit [Ping timeout: 240 seconds]
clacke has quit [Remote host closed the connection]
calle has joined #picolisp
calle has quit [Ping timeout: 268 seconds]
calle has joined #picolisp
<anddam> tankf33der | https://envs.sh/QP4.l <-- boy I cannot read that
<anddam> and I am looking at reference while trying to do so
<abu[m]> Yeah, a bit tough :)
<abu[m]> The prime? function is from the old RSA lib in pil64 btw
<abu[m]> The value of 'L' is a circular list, from the factorization functions
<anddam> no I mean I cannot map the source pil to the let function I see at https://software-lab.de/doc/refL.html#let
<anddam> it is the second form
<anddam> (let (sym|lst 'any ..) . prg)
<anddam> so prg is (let Fmt (need…
<anddam> oh wait
<abu[m]> Yes, the second 'let' is the body of the first
<anddam> D is 2, L is that odd list, then Lst is what gets returned by make
<abu[m]> right
<anddam> and armed with D, L, Lst you run the last (let)
<anddam> that is actually only formatting output, I guess the "odd" list is spacing and formatting rules for terminal
<abu[m]> Exactly
<anddam> so the gist happens in the assignment of Lst from (make)
<abu[m]> No, it is a sequence of divisors
<anddam> I don't know if I can call these "functions"
<anddam> oh
<anddam> so
<anddam> D is the counter, from 2 to 23456789
<anddam> I have to search chop and link
<abu[m]> This is the original one: http://ix.io/441B
<abu[m]> It is an algorithm from Knuth
<abu[m]> The values in L are the increments
<abu[m]> 2 3 5 7 ...
<abu[m]> D+1 D+1+2 D+1+2+2
<abu[m]> And because L is circular, it repeats after a while
<abu[m]> 4 2 4 2 4 6 2 6 .) is added infinitely
<abu[m]> because (++ L) always "pop"s the next value from L
<anddam> I figure the "odd" way that list is defined is what makes it circular
<abu[m]> yes
<abu[m]> (a b c .) is a 3-cell circular list
<abu[m]> reader syntax
<anddam> I remember reading the reference once, it had something about it
<anddam> oh there it is "PicoLisp has built-in support for reading and printing simple circular lists. If the dot in a dotted-pair notation is immediately followed by a closing parenthesis, it indicates that the CDR of the last cell points back to the beginning of that list"
<abu[m]> ah, yes
<anddam> so the list has a warm-up of 1 . 2 . 2 then a circular part
<abu[m]> yep
<abu[m]> So the dot in the middle is needed
<abu[m]> to get the starting cell
<anddam> to split the "run once" from the circular part
<abu[m]> very good!
<anddam> I scratching a bit my head about the (and)
<abu[m]> The 'and' is quite standard Lisp I think
<anddam> I know lisp as much as I know picolisp
<abu[m]> oh, I see
<anddam> (while 'any . prg) 'any is the two expressions (>=) and (and) right?
<abu[m]> You could write (when (and (prime? D) (apply < ...)) (link ...))
<anddam> i.e. prg is last arguments passed to while
<abu[m]> The prg is the and here
<abu[m]> 'any' is (>= ... D)
<anddam> parenthesis don't match, or so it seems to me
<anddam> (link D) ) is closing (and
<anddam> but prg is last element before closing (while
<anddam> and that should be (inc 'D (++ L)) )
<anddam> is that wrong?
<abu[m]> 'prg' is (and ) and (inc ...)
<anddam> two sibling forms?
<abu[m]> You could check the indentation, it is correctly indented
<abu[m]> A prg is a list of exe's
<abu[m]> one exe is (and ) and one is (inc )
<abu[m]> (while (>= )
<abu[m]> (and ...)
<abu[m]> (inc ...) )
<anddam> why is prg a list of exe in (while 'any . prg) and 'any is not?
<anddam> due to the quoting?
<abu[m]> The quoting indicates that 'any' is evaluated (though the exe's in prg may also get evaluated)
<abu[m]> while evaluate the any
<abu[m]> and if non-NIL, it runs 'prg' and loops back
<abu[m]> The goal is the 'link'
<abu[m]> it links D if it is prime and has ascending digits
<anddam> so it checks it's prime, check it's split digits are in increasing order and if so (chain in the and form) links it to D
<abu[m]> yes, but not "links to D". It "links D"
<abu[m]> i.e. puts it into the result
<anddam> oh, right
<anddam> I just read the function
<anddam> "in the current *make* environment"
<anddam> so D is the argument, not the destination
<abu[m]> yeah
<anddam> the environment will get returned at the end of the (make) evaluation
<anddam> I guess
<abu[m]> the destination is implicit
<anddam> it _almost_ makes sense
<abu[m]> exactly
<anddam> two things unclear
<anddam> one is re: Knuth's algo
<anddam> why are the increase steps fixed at those numbers
<anddam> the other is about that while definition (while 'any . prg) why does prg get to be a list of exe and not any
<abu[m]> It is in Vol. 2 of Knuth Art of Computer programming
<anddam> I have recently started SICP
<anddam> I have a long list of stuff to read (yet), a full time job, and a toddler…
<abu[m]> ok, I have it downstairs, but iirc it is "factoring into primes"
<anddam> I guess I won't educate myself in CS before retirement
<abu[m]> no need! :)
<anddam> but it's fun
<abu[m]> You are right with the prg
<anddam> duly noted about the AoCP reference
<abu[m]> cause an exe *is* an any
<abu[m]> and exe is a number, a symbol or a list
<abu[m]> But the meaning is on "execution", the evaluation aspect
<abu[m]> So a 'prg' is a list of 'exe's which are 'any's ☺
<abu[m]> The point is that it is a list
<abu[m]> (including NIL as an empty list)
<abu[m]> The formatted output comes from the 'tab' call BTW
<abu[m]> (apply tab @ Fmt)
<abu[m]> 'Fmt' is a list of ten tens
<abu[m]> : (need 10 10)
<abu[m]> -> (10 10 10 10 10 10 10 10 10 10)
<anddam> the formatting part was almost clear
<anddam> ok at least I can somehow follow it
<anddam> I am still a bit better than before
<abu[m]> cool
<abu[m]> OK, I go to bed now ☺
<abu[m]> A good night to everyone :)
<abu[m]> afp
<anddam> bye
<anddam> thx