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
alexshendi has quit [Ping timeout: 258 seconds]
alexshendi has joined #picolisp
_whitelogger has joined #picolisp
alexshendi has quit [Ping timeout: 244 seconds]
sebboh has quit [Quit: WeeChat 2.3]
orivej has joined #picolisp
f8l has quit [Ping timeout: 252 seconds]
f8l has joined #picolisp
yunfan has joined #picolisp
tankf33der has quit [Quit: Connection closed for inactivity]
orivej has quit [Ping timeout: 250 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 244 seconds]
srini has joined #picolisp
beneroth has joined #picolisp
orivej has joined #picolisp
orivej has quit [Ping timeout: 246 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 246 seconds]
srini has quit [Ping timeout: 256 seconds]
sri_ram has joined #picolisp
sri_ram has left #picolisp [#picolisp]
razzy has left #picolisp ["ERC (IRC client for Emacs 24.5.1)"]
_whitelogger_ has joined #picolisp
<srin_i> But I was trying to achieve non-uniform column size and in doing so, I struck the following bottleneck
<Regenaxer> (for plain text formatting I mean)
<srin_i> i mean obstacle
<srin_i> that can be illustrated by an example...(let L '((a b c) (d e f) (g h i) (j)))
_whitelogger has quit [Ping timeout: 240 seconds]
<srin_i> what is the best way to print the elements of L in a breadth-first way i.e a d g j \n b e h \n ... etc.. I am only looking for a hint, not the actual solution :) since I spent more than a day trying variations of mapcar and nested for loops etc
<srin_i> so I thought there might be a better way
<srin_i> if you could just point me to it :)
<Regenaxer> You can do that with '(apply mapc ...' I think
<srin_i> following does not work : (let L '((a b c) (d e f) (g h i) (j)) (while (find bool L) (for I L (printsp (pop 'I))) (println)))
<srin_i> yes, i tried with apply ...e.g (apply '((X Y Z J) (mapcar printsp X Y Z J)) '((a b c) (d e f) (g h i) (j)))
<Regenaxer> in this case you need two nested loops
<srin_i> works...but I dont want to assume 4 columns
<Regenaxer> (while (car L) (for ...
<Regenaxer> Then you must first find the longest
<Regenaxer> (maxi length L)
<srin_i> the longest sub-list?
<Regenaxer> yes
<srin_i> ok so something similar to the double loop in (let L '((a b c) (d e f) (g h i) (j)) (while (find bool L) (for I L (printsp (pop 'I))) (println)))
<srin_i> except that my termination conditions are not correct yet
<Regenaxer> yes, this is good
<srin_i> (that solution prints infinitely after the first line)
<Regenaxer> or (find pair l)
<Regenaxer> (find pair L)
<srin_i> ah nice
<srin_i> as an aside... when I encounter the infinite loop..I have no option but to hit ^C
<srin_i> then I get thrown into debugger (! line)
<srin_i> how can i exit the debugger? I usually hit ^D and exit picolisp and then restart :)
<Regenaxer> You can get to the top level with ^X
<Regenaxer> or : (quit)
<srin_i> perfect
<Regenaxer> I would do this loop:
<Regenaxer> (let Lst '((a b c) (d e f) (g h i) (j))
<Regenaxer> (map
<Regenaxer> (while (find pair Lst)
<Regenaxer> '((L)
<srin_i> the problem is that for I
<Regenaxer> (and (pop L) (printsp @)) )
<Regenaxer> Lst )
<Regenaxer> (prinl) ) )
<srin_i> (closing my eyes as I dont want to see your solution yet :) :) )
<Regenaxer> :)
<Regenaxer> if you want for
<srin_i> my problem was that in
<Regenaxer> (for (L Lst L (cdr L)) ...
<srin_i> for I L, I is not the actual element, but a copy of the sub-list, so the pop does not pop the element from the sublist
<Regenaxer> right
<Regenaxer> you need to iterate the cells
<Regenaxer> not the CARs
<Regenaxer> (elements)
<srin_i> yes.....agreed, I see now how you got the actual cells
<srin_i> using map...
<Regenaxer> yes
<srin_i> oh the solution with for is elegant. Actually I thought of that too
<Regenaxer> 'map' is perhaps shorter
<srin_i> I mean cdr L..but shouldnt it be mapcar cdr
<srin_i> since we want to throw away the first element of each sublist in every iteration?
<srin_i> I am referring to (for (L Lst L (cdr L))
<Regenaxer> 'mapcar' is not so good, as it builds a new list
<srin_i> so the second for is inside the while then? i.e while (find pair Lst) (for (L Lst L (cdr L)) ....
<Regenaxer> yes
<srin_i> ok....nice...both are good
<Regenaxer> yeah
<srin_i> perhaps for solution is a bit shorter....excellent. I have all the pieces for my multi-column ls..Once I have it, do you think it is worthwhile to link it to the existing example?
<Regenaxer> Good idea
<Regenaxer> though pleac is a bit dead I feel
<Regenaxer> these are a bit silly examples in my opinion, targeted totally to perl's regex matching
<Regenaxer> (if I have a hammer, everything looks like a nail)
<srin_i> ok.....will show you the solution once it works :) and ask you if it is useful. Yes, although pleac (Perl) is not active maybe, I found the examples in https://picolisp.com/wiki/?pce-pleac-arrays very helpful to experiment with....
<srin_i> :) well there are lots of nails around :)
<Regenaxer> true! :)
<srin_i> but for me it is more a place to help me to think of my own example for practical use (as in the ls case) rather than for use as a cookbook for quick answers :)
<Regenaxer> exactly
<srin_i> oh one other question...that always trips me up when it comes to thinking of writing gui code....
<srin_i> with the prefix classes e.g. +Need +Sn +Idx +String etc... how does one keep track of the order that should be followed
<Regenaxer> Always left -> right
<srin_i> I know +Sn must be before +Idx as it modifies it...but can +Need be anywahere?
<srin_i> i.e is +Sn +Idx +Need work as well?
<Regenaxer> well, yes, but in general it depends
<Regenaxer> (+List +Ref +String) is different from (+Ref +List +String)
<Regenaxer> the first indexes each string separately
<Regenaxer> the second indexes the full list
<srin_i> hmmm...and it is likely to be the first one possibly then?
<Regenaxer> Depends what is wanted
<Regenaxer> I think I used both
<Regenaxer> +Need is rather stand-alone
<Regenaxer> But the last one of course is always a relation class
<Regenaxer> non-prefix
<Regenaxer> So each prefix modifies the behavior of what comes after it
<srin_i> the usual thing would be to write +List +String (if one wanted to convey wanting a list of strings), so +Ref +List +String would be natural, but as you say, it may not be what is wanted
<Regenaxer> yes
<Regenaxer> Usually we want to index the strings in the list
<srin_i> yes +List +Ref +String would be desired behavior usually...i think, but you have found use for the other way too....so one must keep in mind the interactions and think where +Idx +Ref etc are being placed
<Regenaxer> T
<beneroth> its a list of indexed strings :)
<Regenaxer> Hi beneroth
<beneroth> or an indexed list of strings (+Ref +List +String)
<beneroth> Hi Regenaxer :)
<beneroth> Hi srin_i :)
<srin_i> ok..will go now and continue with the multicolumn ls...what I love about PL is the ability to build bottom up till the result is impressive :) and I can't believe I did it myself :)
<srin_i> Hi beneroth :)
<srin_i> e.g this is a step in my "ls" at the moment :) (let C 8 (map '((X) (prin (car X))) (mapcar cdr (group (mapcar '((X) (cons (/ (- (car X) 1) C) (cadr X))) L)))))
<srin_i> thats what makes Picolisp such a joy to use...
<srin_i> for me at least :)
<Regenaxer> :)
<Regenaxer> Though I think the mapcar cdr is a bit overknll ;)
<Regenaxer> 'pop' was good
<srin_i> (that was a different list btw)....
<Regenaxer> ok
<srin_i> although i accept that my code may certainly not be very efficient even then :)..Once I have it done, I will ask for input to make more efficient...
<Regenaxer> ok :)
<srin_i> you are saying that mapcar pop is better, if i understood it? I can experiment with that too....
<Regenaxer> no, I meant no mapcar at all
<Regenaxer> but it is not a problem
<srin_i> oh ...interesting...one sec (reading pop doc :) )
<Regenaxer> I think the above is a (by ... group ...
<Regenaxer> But I did not fully study the example
<srin_i> group returns something like (0 "a" "b" "c") (1 "d" "e" "f") ... )
<Regenaxer> T
<srin_i> the mapcar cdr throws away the starting numbers
<Regenaxer> yes, fine
<Regenaxer> 'by' is a shortcut to such behavior
<srin_i> ah...i encountered by in sort
<srin_i> but did not think of it here....
<Regenaxer> (by '((X) (/ (- (car X) 1) C) (cadr X)) group Lst)
<Regenaxer> 'by' is useful only for 'sort' and 'group'
<Regenaxer> we never found another use case :(
<srin_i> :) yes, it would be ideal here...as it would add the group number and take it away automatically
<Regenaxer> May be a research subject for future generatiogs ;)
<srin_i> :)
<srin_i> wow ...that greatly simplifies my inner loop....! not so impressive though :) :)
<srin_i> i mean it does not look so impressive after :)
<Regenaxer> haha :)
<Regenaxer> (- (car X) 1) could be (dec (car X))
<Regenaxer> hmm
<Regenaxer> strange
<srin_i> nice!! (kicking myself for - (car X) 1) :), in c etc -- is automatic, not yet in PL :)
<srin_i> ?
<Regenaxer> (/ (- (car X) 1) C) (cadr X)) is a bit useless
<srin_i> i mean not automatic for me to use
<Regenaxer> The result of the division is ignored
<Regenaxer> If the function is '((X) (/ (- (car X) 1) C) (cadr X))
<srin_i> ah...there is a cons there (cons (/ (- (car X) 1) C) (cadr X))
<Regenaxer> oups, my fault
<Regenaxer> copy/paste
<Regenaxer> Perfect then
<srin_i> np :) it seemed to work, even if it was not efficient...
<srin_i> much better now
<Regenaxer> So the function for 'by' is '((X) (/ (- (car X) 1) C))
<Regenaxer> ?
<Regenaxer> or better '((X) (/ (dec (car X)) C))
<srin_i> yes, the column number is what by will group by
<srin_i> i mean "by" will group by :)
<Regenaxer> T
<Regenaxer> Instead of grouping, you can also loop in a loop
<srin_i> I group the output of ls by column, then print in a breadth-first way...
<Regenaxer> Thats what I meant no need to build a structure with 'mapcar' etc first
<Regenaxer> yes
<Regenaxer> So looping repeatedly, 'pop'ing the sublists each time, is fine too
<Regenaxer> (or even more efficient)
<srin_i> oh interesting..now that i have your example above...i will go back to my starting list (no-sublists) of ls output and see whether i can use these ideas, so I dont have to do the by' etc....
<Regenaxer> ok :)
<srin_i> it may turn out, as you say, that i did not need to do it at all :)
<Regenaxer> The grouping looks at least more impressive ;)
<srin_i> yes...i was happy with myself :)
<Regenaxer> 👍
<Regenaxer> (does such emoji show up?)
<srin_i> yes...(thumbs-up)
<srin_i> (you put utf character?)
<Regenaxer> good to know
<Regenaxer> yes
<Regenaxer> It is pil, so *only* utf8
<Regenaxer> my pil irc client
<Regenaxer> and the emoji I produce with Penti
<srin_i> on your tablet still?
<Regenaxer> Right
<srin_i> when you start building up a file....do you work on command line
<srin_i> building up expressions
<srin_i> and then add them to a file to test it out?
<srin_i> or you add to file, then load, etc?
<Regenaxer> The latter
<Regenaxer> usually
<srin_i> so just have a series of expressions in the file?
<Regenaxer> yes
<Regenaxer> I always have 2 terminals
<srin_i> one for editing the file
<Regenaxer> one with vip and one with repl
<srin_i> and one for loading/reloading the file
<srin_i> inside pil
<Regenaxer> This is usually the repl terminal
<srin_i> yes
<srin_i> ok....i will switch to work that way... the expressions are getting complicated..so file is better :)...
<Regenaxer> Sometimes I copy/paste also selected snippets to the repl for tests
<Regenaxer> depends ...
<Regenaxer> And I restart the repl *very* often
<Regenaxer> sometimes several times per minute, even when debugging GUI parts
<Regenaxer> it is all so fast
<srin_i> me too....but only because I did not know how to escape debugger....
<Regenaxer> The apps start up in milliseconds anyway
<Regenaxer> ok :)
<Regenaxer> ^X ;)
<srin_i> someday...it will be fascinating to observe your work flow!
<Regenaxer> But starting fresh is always good
<Regenaxer> more reproducible
<srin_i> lot to learn from that i think...
<Regenaxer> Well, we did that, right?
<Regenaxer> using 'screen' back then
<Regenaxer> Now I use 'tmux'
<Regenaxer> Sorry, family :) Daughter with boyfriend is here
<srin_i> yes..but now what perhaps I would try to do...is to mimic it....not just observe....before I still use to edit with emacs....especially as there were lots of files (js) etc
<srin_i> ah np
<Regenaxer> He is from Canada btw
<srin_i> yes...you mentioned.. (am still hoping you will come here)....have a great evening..thanks a lot!! :)
<srin_i> maybe in the summer :)
<Regenaxer> :)
<Regenaxer> yeah, lets see
<Regenaxer> this summer I first go to Japan though
<srin_i> nice!
<Regenaxer> end of June, then lets see ...
ubLIX has joined #picolisp
alexshendi has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
ubLIX has quit [Quit: ubLIX]
orivej has joined #picolisp
<beneroth> [OT] Microsoft blunders once more (= Windows 8 (and higher?) security weakness...): https://www.golem.de/news/subdomain-takeover-microsoft-loses-control-over-windows-tiles-1904-140717.html
orivej has quit [Ping timeout: 244 seconds]
orivej has joined #picolisp
ubLIX has joined #picolisp
ubLIX has quit [Ping timeout: 255 seconds]
ubLIX has joined #picolisp
ubLX has joined #picolisp
ubLIX has quit [Ping timeout: 246 seconds]
ubLX has quit [Ping timeout: 244 seconds]
ubLIX has joined #picolisp
ubLIX has quit [Ping timeout: 255 seconds]
ubLIX has joined #picolisp
ubLIX has quit [Ping timeout: 245 seconds]
ubLIX has joined #picolisp
ubLIX has quit [Ping timeout: 245 seconds]
orivej has quit [Ping timeout: 268 seconds]