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
xkapastel has quit [Quit: Connection closed for inactivity]
ubLIX has quit [Quit: ubLIX]
f8l has quit [Remote host closed the connection]
f8l has joined #picolisp
<tankf33der> morning
<tankf33der> beneroth: I've finished my crypto analysis of handshake protocol
<tankf33der> https://upload.disroot.org/r/5brbLEYE#csdGk+rlO2Ug101HyTyGZj7nsokF4ecx4lSxCkTn43U=
<razzy> good morning
<Regenaxer> Hi tankf33der, razzy
f8l has quit [Remote host closed the connection]
f8l has joined #picolisp
razzy has quit [Ping timeout: 252 seconds]
rob_w has joined #picolisp
f8l has quit [Remote host closed the connection]
f8l has joined #picolisp
xkapastel has joined #picolisp
f8l has quit [Remote host closed the connection]
f8l has joined #picolisp
<Nistur> mornin'
f8l has quit [Remote host closed the connection]
f8l has joined #picolisp
<Regenaxer> Hi Nistur
<Nistur> o7
f8l has quit [Remote host closed the connection]
f8l has joined #picolisp
orivej has quit [Ping timeout: 268 seconds]
razzy has joined #picolisp
rob_w has quit [Remote host closed the connection]
f8l has quit [Remote host closed the connection]
rob_w has joined #picolisp
f8l has joined #picolisp
ubLIX has joined #picolisp
orivej has joined #picolisp
lodsw has quit [Ping timeout: 268 seconds]
lodsw has joined #picolisp
f8l has quit [Remote host closed the connection]
f8l has joined #picolisp
f8l has quit [Ping timeout: 246 seconds]
orivej has quit [Ping timeout: 245 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 240 seconds]
ubLIX has quit [Quit: ubLIX]
rob_w has quit [Quit: Leaving]
razzy has quit [Ping timeout: 245 seconds]
orivej has joined #picolisp
razzy has joined #picolisp
orivej has quit [Ping timeout: 260 seconds]
orivej has joined #picolisp
<rick42> hello peeps
<rick42> trying to do in pil what is done in Scheme (for instance) like this:
<rick42> > (substring "Hello, world" 7)
<rick42> "world"
<rick42> the expression under the `let` here comes to mind immediately
<rick42> : (let (Str "Hello, world" Start 7) (pack (tail (- Start) (chop Str))))
<rick42> -> "world"
<rick42> however, is there a better ("pil-ier") way? thanks
<rick42> ... i'm terrible at pil idioms
<rick42> i tried to find a primitive in the Ref first. didn't find. perhaps i missed it?
<beneroth> hey rick42 o/
<Regenaxer> Hi rick42!
<rick42> beneroth: \o
<rick42> Regenaxer: thanks
<rick42> was just now reading this too: https://picolisp.com/wiki/?pce-pleac-strings
<Regenaxer> beneroth found the rosetta entry :)
<rick42> beneroth: thanks, m8!!!
<Regenaxer> the Escape seems wrong in pleac ;)
<Regenaxer> Must be "^["
<Regenaxer> or `(char 27)
alexshendi has joined #picolisp
<rick42> Regenaxer: yes. somebody copy-and-pasted and forgot to change it :)
<Regenaxer> yeah
<rick42> changed :)
<Regenaxer> Thanks! :)
<rick42> yw
<rick42> Regenaxer: is there a builtin identity function in pil?
<rick42> identity function == '((X) X)
<rick42> i'd like to say ((if X idfunc otherfunc) ...)
<rick42> i noticed `id` but that's for dbs
<rick42> actually i need to say ((if X otherfunc idfunc) ...)
<rick42> i can say ofc: ((if X otherfunc '((X) X)) ...)
<rick42> but i was wondering if it was already defined in pil. thanks
<Regenaxer> rick42, you mean pointer equality?
<rick42> nah. just if the value of X is NIL I need to use the identity function
<Regenaxer> ah
<Regenaxer> sorry, was distracted :)
<rick42> forgot that please
<Regenaxer> I use 'prog' for that
<Regenaxer> (prog 123) -> 123
<rick42> i might be looking for seomthing else
<rick42> ah!
<rick42> nice
<Regenaxer> A special function for that would be better
<Regenaxer> (def 'ident prog)
<Regenaxer> or (def 'ident prog1)
<Regenaxer> (def 'nop prog)
<rick42> right. ok
<Regenaxer> many variations of the same behavior
<Regenaxer> or, as you wrote, '((X) X), I was not paying attention ;)
<Regenaxer> 'prog' is more efficient than '((X) X)'
<rick42> ok.
<rick42> thanks
<rick42> how about this one?: what value of Foo gives this: (head Foo (1 2 3)) -> (1 2 3)
<rick42> is there any such value (for Foo)?
<Regenaxer> 3?
<Regenaxer> or (1 2 3)
<rick42> ok
<rick42> thanks
<rick42> (again! :)
<Regenaxer> Same as (copy (1 2 3))
<Regenaxer> :)
<Regenaxer> Where do you need such 'head'?
<rick42> sorry. just trying something silly:
<rick42> (de substring (Str Start Len) (pack (head (or Len (length Str)) (nth (chop Str) (inc Start)))))
<Regenaxer> You can avoid the 'length' call
<rick42> # Start is assumed to be zero-based; hence, `(inc Start)`.
<rick42> oh ok how?
<Regenaxer> ok, though pil is always 1-based
<Regenaxer> 'nth' returns the rest anyway
<rick42> yes (that's one reason why the exercise is silly :)
<Regenaxer> :)
alexshendi has quit [Read error: Connection reset by peer]
<beneroth> have a good time friends :)
<beneroth> bbl
<rick42> cu m8!
<Regenaxer> cu beneroth!
<Regenaxer> Back to the above
<Regenaxer> as both 'length' and 'head' are expensive, I would avoid them if not needed
<rick42> ok
<Regenaxer> duplicates some code, or needs 'let'
<rick42> looking for this, example usage
<rick42> -> "wor"
<rick42> -> "world"
<rick42> : (substring "Hello, world" 7)
<rick42> : (substring "Hello, world" 7 3)
<Regenaxer> ok
<Regenaxer> So perhaps
<Regenaxer> (let L (nth (chop Str) ...
<Regenaxer> then (if Len ... L)
<Regenaxer> ... being head
<Regenaxer> (if Len (head @ L) L)
<Regenaxer> not soo beautiful ;)
<rick42> ok i see
<Regenaxer> but avoiding 'head' is good as it copies
<rick42> but performant and still clear
<Regenaxer> you could avoid 'head' and be destructive
<Regenaxer> with 'con'
<Regenaxer> (con (nth L Len))
<Regenaxer> So no copying takes place
<Regenaxer> it is safe because L was created freshly with 'chop'
<rick42> never noticed `con` before in the Ref. Neat!
<Regenaxer> yeah
<Regenaxer> more "efficient" :)
<Regenaxer> : (let L (nth (chop "abcdefghi") 3) (con (nth L 4)) L)
<Regenaxer> -> ("c" "d" "e" "f")
<rick42> hehehe nice one
<Regenaxer> bbl
jibanes has quit [Ping timeout: 252 seconds]
jibanes has joined #picolisp
<Regenaxer> ret
<rick42> Regenaxer: wb. see section 1.1.10 in https://picolisp.com/wiki/?pce-pleac-strings
<Regenaxer> I see! You added that now?
<rick42> yes :)
<Regenaxer> It is the above version
<Regenaxer> :)
<rick42> yes with the con (the final version)
<rick42> the "dumb" version is in there too (as a "lesson learned")
<rick42> also I made Start one-based (like other pil funcs)
<Regenaxer> Yeah, good to show both
<Regenaxer> I would stay with the standard indentation though
<Regenaxer> a bit hard to get the flow
<rick42> didn't I use standard (3-space) indentation? i meant to
<Regenaxer> also what goes on a new line
<Regenaxer> as 'pretty' does
<Regenaxer> or pilPretty
<Regenaxer> I would do
<Regenaxer> (de substring (Str Start Len)
<Regenaxer> (pack
<Regenaxer> (let L (nth (chop Str) Start)
<Regenaxer> (and Len (con (nth L Len)))
<Regenaxer> L ) ) )
<Regenaxer> or how about
<Regenaxer> (de substring (Str Start Len)
<Regenaxer> (let L (nth (chop Str) Start)
<Regenaxer> (and Len (con (nth L Len)))
<Regenaxer> (pack L ) ) )
<Regenaxer> (de substring (Str Start Len)
<Regenaxer> (let L (nth (chop Str) Start)
<Regenaxer> (and Len (con (nth L Len)))
<Regenaxer> (pack L) ) )
ubLIX has joined #picolisp
<Regenaxer> I found the pleac tasks all a bit silly
<Regenaxer> very much tailored to regexp handling in Perl
<Regenaxer> (if you have only a hammer, ...
<rick42> ah, yes. trying to do non-pil things. silly indeed
<Regenaxer> :)
<rick42> ok, the indentation is fixed (hopefully)
<rick42> thanks
<rick42> I used (pretty 'code) in the repl
<Regenaxer> Thanks! Perfect
<Regenaxer> :)
<rick42> yw. ty!
<rick42> ok back to work for me. cu later, Regenaxer!
<Regenaxer> CU rick42! :)
<rick42> ok i didn't see you new versions (with `and`). i'm an idiot
<rick42> ok fixed. now back to work :)
<Regenaxer> oh, not important :)
<Regenaxer> It is just that if I see 'if' I expect an 'else' part
<Regenaxer> But 'if' is fine
f8l has joined #picolisp
orivej has quit [Ping timeout: 252 seconds]
razzy has quit [Ping timeout: 268 seconds]
ubLIX has quit [Quit: ubLIX]
orivej has joined #picolisp
mario-go` has joined #picolisp
inara` has joined #picolisp
inara has quit [Ping timeout: 268 seconds]
lodsw has quit [Ping timeout: 268 seconds]
mario-goulart has quit [Ping timeout: 268 seconds]
lodsw has joined #picolisp
ubLIX has joined #picolisp