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
andyjpb has quit [Ping timeout: 260 seconds]
orivej has quit [Ping timeout: 248 seconds]
alexshendi has joined #picolisp
alexshendi has quit [Ping timeout: 265 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 240 seconds]
mtsd has joined #picolisp
<beneroth> hi all
<mtsd> Hello beneroth!
<beneroth> Good morning mtsd !
<beneroth> :)
<Nistur> Why is it morning again?
<beneroth> because the earth turned around.
<beneroth> it does that sometimes.
<Nistur> :P
andyjpb has joined #picolisp
<aw-> hi all, small Pil quiz: from the list: '("ONE" ("a" "b" "c" "d") "TWO") <-- how to get: ("b" "c" "d")
<aw-> i'm trying with 'cadr, 'cdadr etc... can't quite get it
<aw-> (cdr (cadr 'lst)) seems to work..
<Regenaxer> cadar
<Regenaxer> no :)
<Regenaxer> you need the
<Regenaxer> CDDR from the CADR
<Regenaxer> cddadr
<Regenaxer> ah, sorry again, starting from "b" is one d less cdadr
<Regenaxer> You said you tried 'cdadr'?
<Regenaxer> : (cdadr '("ONE" ("a" "b" "c" "d") "T"))
<Regenaxer> -> ("b" "c" "d")
<beneroth> this is kinda the pointer arithmetic of lisp ...
<Regenaxer> yeah :)
orivej has joined #picolisp
<aw-> ah! cdadr works!
<aw-> Regenaxer: thanks! I'm not sure why i didn't try it
<aw-> how did you figure it out?
<aw-> i thought i tried it but i didn't haha
<beneroth> maybe write a little console program which takes a list and an element as input, and outputs the right picolisp function to fetch it? :P
<beneroth> hm..could even be a pilog task ..hmm
<aw-> pilog makes sense
<tankf33der> cdadr ? i did in head.
<beneroth> yeah its a FSM task.
<beneroth> tankf33der, you are probably the most skilled in this :)
<tankf33der> nono, Regenaxer much skilled, i cant create picolisp
<aw-> I think i haven't yet fully grok'd the (c[ad]* syntax/functionality yet
<beneroth> I look at it like tree/path-walking
<beneroth> a -> go/take to the first element, d -> go/take to the rest (second and other elements)
<tankf33der> and do it in reverse
<beneroth> so cdadr -> c - d: take rest = '(("a" "b" "c" "d") "T") -> a: take first '("a" "b" "c" "d") -> d: take rest = '("b" "c" "d")
<beneroth> you could also understand 'd' as "skip first element"
<aw-> beneroth: brilliant!
<beneroth> tankf33der, what do you mean with "do it in reverse" ?
<aw-> this explanation is very clear
<Regenaxer> Same. I do it backwards, ie taking CADR (second element) then from that the CDR = (cdr (cadr )) = (cdadr )
<beneroth> yeah I was just surprised myself :D
<beneroth> ah, I see!
<aw-> beneroth: is this also how you're selling your brain?
<beneroth> yeah, backwards needs a bit more training xD
<beneroth> aw-, sometimes. apparently people often think I'm good at explaining. I'm currently preparing a C# course for non-programmers.
<Regenaxer> cool!
<beneroth> I heavily underestimated the time needed to prepare the material (handout/pdf) :(
<beneroth> using LaTex, being a novice...
<beneroth> the more I use it the uglier I find it. I mean, elegant concept but so much cruft...
<aw-> so, (cdadr) = (cdr (car (cdr 'Lst)))
<aw-> beneroth: doesn't sound fun
<Regenaxer> yes, c@r supports up to 4 d's or r's
<aw-> right... total 4, like 'caaaar or 'cddddr or 'caaddr etc...makes sense, very useful
<aw-> is that a standard lisp thing? or only PicoLisp?
<Regenaxer> This is standard, don't know how many d's and r's others have
<Regenaxer> : (by length sort (what "c@r"))
<Regenaxer> -> (car cdr clr caar cadr cdar cddr char curr caaar caadr cadar caddr cdaar cdadr cddar cdddr chdir caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr center)
<beneroth> aw-, I like the explaining part, but hate the "argh why does this not render nicely"-part. and now I'm stressed because I underestimated the required time, and I have a fixed deadline.
<Regenaxer> Perhaps some compiler build them at compile time to unlimited length
<beneroth> prolly not, that would be to simple and practical, no? :P
<Regenaxer> Even the blind chicken finds a corn ;)
<Regenaxer> aw-, another option would be 'nth'
<Regenaxer> (nth Lst 2 -1)
<beneroth> but yeah, this combinations are the reason why this (unfamiliar) car/cdr terms stayed with lisp, (second (first (second List))) and (secondfirstsecond List) is just uglier
<Regenaxer> yeah, some "clever" Lisps went away from car and cdr
<beneroth> I think Common Lisp has first and second... but car/cdr, too
<beneroth> not sure
<Regenaxer> yes, could be
<Regenaxer> car/cdr it has for sure
<beneroth> it was heavily discussed in the beginning of Arc (pg's Lisp), but then kept just because it's practical, so new people just have to get used to it
<Regenaxer> good
<aw-> hmmm
<beneroth> afaik Arc is mostly dead, no? It promised a lot and was never fully finished afaik. And most of what it promised picolisp delivers for a much longer time already.
<aw-> so other languages don't have anything even close to (cddadr) ?
<beneroth> non-lisps haven't, afaik
<Regenaxer> CL surely has
<Regenaxer> T
<aw-> yes I meant non-lisps
<beneroth> unless you want to compare it to C-style pointer arithmetic, that is somewhat comparable I find.
<Regenaxer> I don't know any lang with similar list operations in general
<beneroth> aw-, java and C# have stuff like List.First().Second().First() bla
<Regenaxer> tankf33der, thanks
<tankf33der> https://docs.racket-lang.org/reference/pairs.html#%28part._.Pair_.Accessor_.Shorthands%29
<aw-> beneroth: oh right right, yeah i knew about those actually
<beneroth> list and mapping operations are leaking into mainstream languages. natural result of the 60 year long trend of taking stuff from lisp without reall ybecoming lisp.
<beneroth> tankf33der, thanks!
<beneroth> racket is considered a lisp dialect afaik, no?
<Regenaxer> A Scheme
<aw-> scheme
<Regenaxer> So in many ways similar to Lisp
<beneroth> and scheme is a major branch within the lisp family. or is this kinda wrong statement?
<aw-> oh yeah, Racket seems to have up to 4 as well
<Regenaxer> I tend to say that it is not a real Lisp
<Regenaxer> But thats a matter of definition
<beneroth> the LINQ in C# is a bit similar to lisp (lambda/anonymous functions, and a kind of map functions). Implemented kinda like C++ free operators / global methods/functions. It's used either to process lists or generate SQL queries during runtime.
<beneroth> heavy breach with the "normal" C# syntax, and depending on if you operate on lists in memory, or actually on DB stuff (SQL), it behaves a bit differently and not everything is allowed in both contexts
<beneroth> highly confusing.
<beneroth> new thing in C# from recent years.. now C# is kinda a mix of completely different syntaxes and concepts, so not really well usable without an assisting IDE I find
<beneroth> e.g. db.Users.Where(u => u.age < 22).SelectMultiple(u => u.Siblings).OrderBy(u => u.age); -> returns an iterator/cursor into the SQL DB.
<beneroth> db.Users.Where(u => u.age < 22).SelectMultiple(u => u.Siblings).OrderBy(u => u.age).ToList(); -> returns a list of objects in memory
<Regenaxer> :o
<beneroth> some statements are not allowed within the anonymous functions depending if its a list in memory or if it mapped/generates to a SQL query
<beneroth> a mess
<beneroth> but yeah, one step closer to approximate some lisp and even graph DB functionality
<beneroth> Java introduced similar things afaik, but I don't program nor follow Java much
<beneroth> tankf33der, sweet!
<Nistur> beneroth: Linq is all good and everything, but it makes some god awful looking C# code
<Nistur> and a pain in the neck to debug when you chain it all like that
<aw-> tankf33der: haha +1
<aw-> thanks
<beneroth> Nistur, exactly
<beneroth> and I find it extremely ugly that it might look the same, but works (and is!) something completely different depending on context
<beneroth> but that is an issue with other stuff in C# too
<beneroth> e.g. Razor C# (C# used in the HTML pages of an web application) is different from usual C# (e.g. no foreach loop)
<Nistur> I have zero experience with that
<Nistur> I've used a bit of Linq because it adds a bunch of functionality to collections that was missing, but I use it VERY sparingly
<beneroth> and me personally I also hate non-technical limitations like "you are not allowed to change a list you are currently iterating over". yeah can be a trap, but well I used to know what I do.
<beneroth> s/I used/I'm used/
<beneroth> C# is for the enterprise drones to get stuff done without being able to blow much up.
<aw-> Regenaxer: there's an unexpected behaviour in 'allowed <-- if called without arguments, it resets *Allow to (NIL)
<aw-> shouldn't it check for an Lst before doing (cons NIL NIL) ?
<Regenaxer> oh, haha, well this makes not much sense
<Regenaxer> 'allowed' *always* sets to the argument(s)
<Regenaxer> NIL is just one special case
<beneroth> it's not a check, it is a specification
<beneroth> (whitelisting)
<aw-> hmmm
<aw-> so, (allowed) essentially blacklists everything
<aw-> by design?
<Regenaxer> If *Allow is not empty, it is a whitelist
<Regenaxer> if it is empty, everything is allowed
<beneroth> so can go wrong easily, eh? :P
<aw-> if *Allow is (NIL), it is a whitelist of nothing = blacklist
<aw-> blacklist of everything*
<beneroth> that would be more consequent
<aw-> whitelist of nothing
<aw-> ok just checking
<beneroth> but as I understand Regenaxer, the *Allow mechanics changes behaviour when *Allow is NIL
<aw-> seems dangerous to programmatically call (allowed)
<aw-> beneroth: no, when *Allow is (NIL)
<beneroth> ah!
<beneroth> wow
<aw-> it works fine when it's NIL
<beneroth> ok
<aw-> no big deal, i just wanted to be sure it wasn't a mistake
mtsd has quit [Quit: Leaving]
<beneroth> aw-, maybe do (redef allowed Lst (ifn Lst (quit "(allowed) called without arguments") (apply 'allowed Lst)) to secure against this programmer mistake?
<beneroth> you could put this redef into a separate script you only load for testing/pre-production, and leave it away in production code (overhead)
<beneroth> I haven't tested if the redef above is actually correct, but you get the idea ;)
<Regenaxer> I think he would quickly notice without the redef
<Regenaxer> "not allowed" messages
<beneroth> ah, I misunderstood
<beneroth> so (off *Allowed) -> everything allowed. but (allowed) equals (setq *Allowed '(NIL)) -> empty blacklist, nothing allowed
<beneroth> ok
<beneroth> thanks for the correction
<aw-> beneroth: yes
<aw-> no need to redef, i just choose to define (allowed) with hardcoded list instead ;)
<aw-> less dangerous
orivej has quit [Ping timeout: 276 seconds]
orivej has joined #picolisp
alexshendi has joined #picolisp
alexshendi has quit [Ping timeout: 240 seconds]
alexshendi has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
alexshendi has joined #picolisp