ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Picolisp latest found at http://www.software-lab.de/down.html | check also http://www.picolisp.com for more information
orivej has joined #picolisp
rob_w_ has joined #picolisp
rob_w has quit [Ping timeout: 252 seconds]
f8l has quit [Ping timeout: 260 seconds]
f8l has joined #picolisp
orivej has quit [Ping timeout: 265 seconds]
aw- has joined #picolisp
orivej has joined #picolisp
rob_w has joined #picolisp
miskatonic has joined #picolisp
mtsd has joined #picolisp
<mtsd> Good morning
<Regenaxer> Good morning mtsd
<t4nkf33der> morning
<Regenaxer> Good morning t4nkf33der
bene|off is now known as beneroth
<beneroth> Good morning Regenaxer, mtsd, t4nkf33der
<Regenaxer> Hi beneroth
<miskatonic> mornin'
<Regenaxer> hi miskatonic
<mtsd> Hi beneroth
<t4nkf33der> i want implement this
<aw-> cool
<aw-> hi all!
<aw-> I'm looking for a way to make this faster: http://rosettacode.org/wiki/Permutations_with_repetitions
<aw-> (de permrep (N Lst) ... where N = 3 and (length Lst) = 256 ... (256^3)
<beneroth> maybe (later) helps, see ref (there is even an mapcam example)
<beneroth> I gotta go
<beneroth> bb
<aw-> thanks beneroth
miskatonic has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
<t4nkf33der> beneroth: aw-: no
<t4nkf33der> just needs create iterator
<aw-> oh.. this is recursing!
<aw-> yeah beneroth's won't work anyways.. too many file descriptors needed
<t4nkf33der> aw-: i will try implement without recursion
<Regenaxer> tricky
<t4nkf33der> i found code how i did cartesian product iterator on coroutines
mtsd has quit [Remote host closed the connection]
<t4nkf33der> its the same. i will show it if success.
<t4nkf33der> done
mikeyhc has joined #picolisp
<t4nkf33der> aw-: how you will iterate (** 256 3) items? coroutine generator? inside-loop?
<Regenaxer> cool! But isn't a coroutine overkill here?
<t4nkf33der> since i dont know how to stop somewhere in the middle and start over again coroutine is ok
<Regenaxer> right, but the normal Lisp way is to pass in a function taking each result
<Regenaxer> coroutine is ok, but a bit expensive I believe
<t4nkf33der> aw- can easily convert it to something.
<Regenaxer> T
<Regenaxer> I prefer for permutations this pattern (used in several places):
<Regenaxer> (recur (L) # Permute
<Regenaxer> (if (cdr L)
<Regenaxer> (do (length L)
<Regenaxer> (recurse (cdr L))
<Regenaxer> (rot L) )
<Regenaxer> ... do something ...
<Regenaxer> ie in the "false" branch of the 'if' you have the permuted result
<aw-> i think there's already a (permute) function
<Regenaxer> in Lst
<Regenaxer> aw-, yes, but it generates a full list of *all* results
<aw-> Regenaxer: is it faster than the rosetta code example?
<Regenaxer> not practical if you have many results
<aw-> yes i want all results
<aw-> 256^3
<Regenaxer> yes, but it builds a list first
<Regenaxer> may be bigger than memory
<Regenaxer> and produces garbage
<aw-> yeah,... i stopped it when i reached ~500Mb of memory usage
<aw-> haha
<Regenaxer> allocates a big heap
<Regenaxer> yep
<Regenaxer> The above pattern is the fastest I believe
<aw-> what i would like is to write to a file on each iteration.. the file is in tmpfs so no problem
<Regenaxer> yes, so in the ... above
<aw-> but maybe that's too much context switching?
<Regenaxer> for output?
<aw-> yes
<Regenaxer> (out "a" ... permute ... (print Lst))
<aw-> no
<Regenaxer> no context switch
<aw-> that only does one write
<Regenaxer> no
<Regenaxer> all
<aw-> yes one write of all
<aw-> i want many writes on one
<Regenaxer> o
<Regenaxer> no
<aw-> with append
<Regenaxer> 'print' buffers
<Regenaxer> it is the same
<Regenaxer> many 'print's or one big 'print'
<aw-> really?
<aw-> if I do (mapcar prinl Lst), those prinl statements are buffered until mapcar is complete?
<Regenaxer> All printing goes through a buffer of BUFSIZ
<Regenaxer> 8 KiB
<aw-> t4nkf33der: thanks for solution
<Regenaxer> So context switch (ie a system call) is for every 8 KiB, no matter how they were generated
<Regenaxer> So in my belief the really optimal permutation is always this:
<Regenaxer> (let (Lst (range 1 6) L Lst) (recur (L) # Permute (if (cdr L) (do (length L) (recurse (cdr L)) (rot L) )
<aw-> right.. which is pretty much what i'm doing
<Regenaxer> The last line may be anything
<Regenaxer> (printsp Lst) is some other logic usually
<aw-> your optimal solution is too slow/memory intensive for 256^3
<Regenaxer> nope
<Regenaxer> It is the fastest
<Regenaxer> must bene
<Regenaxer> be
<Regenaxer> because it does no useless consing
<Regenaxer> generates the results one by one
<aw-> hmmm
<Regenaxer> eg. to filter the results:
<aw-> ok wait i will try
<Regenaxer> (let (Lst (range 1 6) L Lst) (make (recur (L) # Permute (if (cdr L) (do (length L) (recurse (cdr L))
<Regenaxer> you see the pattern?
<Regenaxer> I used this many times
<Regenaxer> alwast a different final part
<Regenaxer> but the recursion pattern is the same
<Regenaxer> instead of 'make' and 'link' you may also call a passed-in function
<Regenaxer> Lisp-style :)
<aw-> i dont see link
<Regenaxer> (if (someCondition) (link Lst) ) ) ) ) )
<aw-> where?
<Regenaxer> 12 lines above ;)
<aw-> sorry i don't understand what you pasted, there's no formatting or anything
<Regenaxer> oh, you client removes indentation?
<aw-> and it's incomplete
<aw-> no it doesn't
<aw-> your first paste was fine
<Regenaxer> The one with 'printsp'?
<aw-> ???
<Regenaxer> It is the minimal example anyway
<aw-> none of your examples work
<aw-> they are incomplete
<Regenaxer> I just tried
<aw-> (let (Lst (range 1 6) L Lst)
<aw-> (make
<aw-> (recurse (cdr L))
<aw-> (do (length L)
<aw-> (if (cdr L)
<aw-> (recur (L) # Permute
<aw-> this is incomplete
<aw-> i dont understand it
<Regenaxer> (let (Lst (range 1 3) L Lst) (recur (L) (if (cdr L) (do (length L) (recurse (cdr L)) (rot L) )
<Regenaxer> (1 2 3) (1 3 2) (3 1 2) (3 2 1) (2 3 1) (2 1 3)
<Regenaxer> Think about it
<Regenaxer> ;)
<Regenaxer> First of all: Why does it not work for you? Paste error or IRC problems?
<aw-> ok i'll look at this later
<aw-> i've been thinking all day, tired now
<aw-> thank you!
<Regenaxer> ok
<aw-> oh this doesn't use repetitions either
<aw-> ok ok i'll be back later or tomorrow
<aw-> goodnight
aw- has quit [Quit: Leaving.]
rob_w has quit [Quit: Leaving]
miskatonic has joined #picolisp
miskatonic has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
rob_w_ has quit [Quit: Leaving]
rob_w has joined #picolisp
<t4nkf33der> hkdf implemented.
orivej has quit [Ping timeout: 264 seconds]
m_mans has quit [Ping timeout: 260 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 248 seconds]
rudha has joined #picolisp
rha_ has joined #picolisp
rudha has quit [Ping timeout: 276 seconds]
miskatonic has joined #picolisp
rha__ has joined #picolisp
rha_ has quit [Ping timeout: 256 seconds]
orivej has joined #picolisp
rha__ has quit [Quit: Leaving]
miskatonic has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
alexshendi has joined #picolisp
rob_w has quit [Quit: Leaving]
orivej has quit [Ping timeout: 268 seconds]
ChanServ has quit [shutting down]
ChanServ has joined #picolisp
alexshendi has quit [Ping timeout: 256 seconds]
libertas has quit [Ping timeout: 268 seconds]