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
orivej has quit [Ping timeout: 272 seconds]
<rick42> pil question: i know i can find member of a list `Lst` that has optimal cost with `(by cost sort Lst)`
<rick42> (given a `cost` function)
<rick42> if i want to see which member of `Lst` that is, i can say `(car (by cost sort Lst))`
<rick42> now: what if there are "ties" (for instance three members of `Lst` have optimal cost)?
<rick42> what's the best way to return all of them? thanks :)
ubLIX has quit [Quit: ubLIX]
viaken has quit [Quit: reboot]
viaken has joined #picolisp
<rick42> here's is the code I was playing with that prompted that question:
<rick42> i'm not happy with the last expression at the top level
<rick42> (after the comment that says `# Application of the above to find all solutions`)
<rick42> seems that there might be a better way ...
<rick42> (there's usually a better way in pil that i don't know about :)
<rick42> anyway, please comment upon any of the code, so I can learn. thanks!
orivej has joined #picolisp
_whitelogger has joined #picolisp
_whitelogger has joined #picolisp
_whitelogger has joined #picolisp
<Regenaxer> Good morning rick42!
<Regenaxer> Pehaps 'maxi' and 'filter'?
_whitelogger has joined #picolisp
<Regenaxer> rick42: How about this http://ix.io/1K0e ?
<Regenaxer> Or this http://ix.io/1K0f ?
<Regenaxer> Algorithmically more expensive (depends on 'cost'), but perhaps faster due to less function call overhead
<tankf33der> o/
<tankf33der> second night in the row coding in picolisp in sleep. like nightmare. recursion, db and gui. sigh.
<Regenaxer> Hi tankf33der! Good!! :)
orivej has joined #picolisp
orivej has quit [Ping timeout: 246 seconds]
inara has quit [Quit: Leaving]
inara has joined #picolisp
orivej has joined #picolisp
orivej has quit [Ping timeout: 244 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 258 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 248 seconds]
<rick42> thanks, Regenaxer!
<Regenaxer> :)
<Regenaxer> I'd prefer that too
<Regenaxer> yes, 'mini' of course ;)
Regenaxer has left #picolisp [#picolisp]
Regenaxer has joined #picolisp
<Regenaxer> Instead of '(apply max' I would use @@ after 'maxi'
<Regenaxer> And constants like
<Regenaxer> (def 'Costs '((A . 1) (B . 2) (
<Regenaxer> cold be
<Regenaxer> (de Costs (A . 1) (B . ...
<rick42> ok
<rick42> yes, in fact I did use @@ after mini
<rick42> ah, you mean in `cost`
<rick42> got it. thanks
<Regenaxer> ok, not sure :)
<rick42> (prob (maxi ...) @@) seems to be slightly faster than (apply (max ...))
<Regenaxer> Perfect
<Regenaxer> The basic problem with 'apply' is that it expands the arguments on the stack, so it is expensive in terms of stack space and time (relatively)
<Regenaxer> So I don't use 'apply' for potentially unlimited lists (short lists are perfectly fine)
ubLIX has joined #picolisp
<rick42> got it. thanks again
<rick42> i now have the `cost` function as:
<rick42> (let cost-person '((Person) (cdr (assoc Person Costs)))
<rick42> (de cost (Path)
<rick42> (sum '((Move) (maxi cost-person Move) @@) Path)))
<rick42> got rid of the `lookup` function; everything can be localized
<rick42> tankf33der: you have reached heights in your picolisp journey that i could not hope to reach: literally coding in your sleep. maybe in a few more years of hacking picolisp, you will be able to levitate like Regenaxer does :)
clacke_movim has left #picolisp [#picolisp]
clacke_movim has joined #picolisp
<tankf33der> pil32 passed tests on gcc 9.1
<Regenaxer> rick42, if 'Person' is an internal or external symbol, you can replace 'cost-person' with 'get'
<Regenaxer> (get Costs Person)
<rick42> so Regenaxer I could "tag" each symbol A, B, C or D with a Cost property?
<Regenaxer> Yes, that too. But 'get' on a list does a (cdr (asoq ...))
<Regenaxer> 'asoq' uses '==', so the CARs should be symbols
<Regenaxer> (or short numbers in pil64)
<Regenaxer> : (get '((a . 1) (b . 2) (c . 3)) 'b)
<Regenaxer> -> 2
<rick42> ok that's looks good
<Regenaxer> But properties are more general and useful in my tyste
<Regenaxer> taste
<rick42> thanks!
* rick42 is not levitating yet, but merely feels "a bit" lighter
<rick42> :)
<Regenaxer> :)
ubLIX has quit [Quit: ubLIX]
ubLIX has joined #picolisp
orivej has joined #picolisp
orivej has quit [Ping timeout: 246 seconds]
ubLIX has quit [Quit: ubLIX]