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
reed_ has joined #picolisp
reed_ has quit [Quit: Page closed]
orivej has quit [Ping timeout: 264 seconds]
reed has quit [Ping timeout: 260 seconds]
aw- has joined #picolisp
<aw-> Regenaxer: hi
<Regenaxer> Hi aw-!
<Regenaxer> Still up?
<aw-> still?
<aw-> it's 2:30pm
<Regenaxer> oh, right!
<Regenaxer> 7 hours later
<aw-> hahaha
<aw-> i sleep sometimes ;)
<Regenaxer> good :)
<aw-> i'm looking for a function similar to (append), but which takes a list of lists as argument
<Regenaxer> apply conc or append
<aw-> ex: '((1 2 3 4) (5 6 7 8)) -> (1 2 3 4 5 6 7 8)
<Regenaxer> conc if the lists are fresh
<Regenaxer> (apply append Lst)
<Regenaxer> (apply conc Lst)
<aw-> what do you mean 'fresh' ?
<Regenaxer> Freshly created, as opposed to be literals (constants) in the code
<Regenaxer> The issue of destructive vs non-destructive operations
<Regenaxer> (conc (read) (read)) is fine
<aw-> oh right, yes conc is destructive
<Regenaxer> (conc (1 2 3) (read)) is not
<Regenaxer> Most lists in a typical program are "fresh"
<Regenaxer> I don't know a better term
<Regenaxer> But if not sure, 'append' is better though a little less efficient
<aw-> hmmm
<aw-> yes i get it
<aw-> ok next one
<aw-> ex: '((1 2 3 4) (5 6 7 8)) -> (1 2 3 4 0 5 6 7 8)
<Regenaxer> ok
<aw-> i want to insert something in between each list
<Regenaxer> another list or so?
<Regenaxer> maplist or mapcon
<aw-> one sec
<aw-> no, i want to make one list but i want to insert something in between each item in the list
<aw-> ex: '((1 2 3 4) (5 6 7 8) (9 9 9)) -> (1 2 3 4 0 5 6 7 8 0 9 9 9)
<aw-> in this case '0' was inserted
<Regenaxer> ok, let me try
<aw-> i've tried a hundred different things hahaha
<aw-> clearly i don't grasp list processing well enough
<aw-> it's a bit like (glue), except i don't want a transient symbol
<aw-> something like: (chop (glue 0 '((1 2 3 4) (5 6 7 8) (9 9 9)))) ... but this is not good, obviously
<Regenaxer> Hmm, mapcon works:
<Regenaxer> (mapcon '((L) (if (cdr L) (append (car L) (cons 0)) (copy (car L)))) '((1 2 3) (4 5 6) (7 8 9)))
<Regenaxer> But perhaps 'make' in a loop is easier?
<aw-> oh wow that's complex
<Regenaxer> It is shorter:
<Regenaxer> (make (for (L '((1 2 3) (4 5 6) (7 8 9)) L) (chain (copy (++ L))) (and L (link 0]
<Regenaxer> Note the 'copy' in (chain (copy (++ L)))
<Regenaxer> as 'chain' is destructive
<aw-> hmmm ok i think i will do something different
<Regenaxer> Why?
<aw-> my opinion, if i end up doing something so complex, i need to go back and look at my problem ffrom a different angle
<Regenaxer> yes, that's often good
<aw-> gives me a bad feeling if i'm doing something like this
<Regenaxer> However the above is not complex at all
<Regenaxer> chains the list, looks if there is more, and links 0
<Regenaxer> pretty simple
<aw-> :\
<aw-> ok i have another question
<aw-> if i have a list with NIL in various locations
<aw-> how can I remove them?
<aw-> easy way*
<Regenaxer> (filter bool L)
<aw-> ex: '(NIL 1 2 3 NIL 4 NIL 5 6 7 NIL 8)
<aw-> bool?!
<Regenaxer> or (filter prog L)
<aw-> ahhh
<aw-> lovely
<aw-> yeah i was looking for a (=NIL) function or something
<Regenaxer> oh ;)
<Regenaxer> it is 'not'
<aw-> right
<aw-> thanks!
<Regenaxer> There is never sense in comparing something with NIL
<aw-> right, better to use (unless), (or) ... etc
<Regenaxer> yeah
<Regenaxer> ifn
groovy2shoes has quit [Ping timeout: 265 seconds]
groovy2shoes has joined #picolisp
<aw-> ok one more question
<aw-> (clip) removes all whitespace from both sides of list
<aw-> (trim) removes trailing whitespace
<aw-> is there something to remove only preceding whitespace?
<Regenaxer> not directly, how about (while (and L (sp? (car L))) (++ L)) ?
<aw-> it would be really useful ;)
<Regenaxer> Where would that be useful?
<aw-> (rtrim) or something
<aw-> well, anytime there's a list of whitespace at the front of the list?
<Regenaxer> I never had a use case
<Regenaxer> yes, but then 'clip' is more useful
<Regenaxer> typically user gui input
<Regenaxer> may have blanks on both sides
<Regenaxer> So why remove *only* on front?
<aw-> why not?
<aw-> it's a use case
<aw-> just because you don't need it doesn't mean others don't need it
<Regenaxer> Where do you need to preserve trailing blanks?
<Regenaxer> It is bad language design if you throw in lots of useless functions
<aw-> perhaps, i guess just regular string parsing has these situations
<Regenaxer> just because the designer thinks somebody *may* need it some time
<Regenaxer> yes, so it is a simple one-liner
<Regenaxer> But *where* would one need it?
<aw-> well no, it's like having a car that can only turn left, so if you want to go right then you need to make 3x90deg turns?
<Regenaxer> haha
<Regenaxer> For a car you definitely *need* right turns
<Regenaxer> bad example
<aw-> i don't understand why there's a function to clip all whitespace or only trailing, but nothing to clip the front
<aw-> ;)
<aw-> haha yes car analogies are not well suited for programming
<Regenaxer> :)
<Regenaxer> trailing whitespace is usually garbage
<Regenaxer> eg typed by the user at the end of a line
<Regenaxer> leading whitespace is not
<Regenaxer> alignments
<Regenaxer> So it is not as symmetric as left and right turns
<aw-> in Ruby there was lstrip() and rstrip()
<aw-> i can't imagine if they only provided rstrip()
<Regenaxer> Not our problem here
<aw-> lstrip(), rstrip(), strip()
<aw-> it's logical
<Regenaxer> Again: Give me an example where you need it!
<Regenaxer> I never needed it
<Regenaxer> Always 'clip' normally
<Regenaxer> And if you need it in seldom cases, don't bloat the language with it
<Regenaxer> It is trivial to write directly inline
<aw-> ok so let's use this example, i have this list: '((" " "a" "b") (1 2 3) (" " "c" "d" " "))
<aw-> how would you convert it to: '("a" "b" 1 2 3 " " "c" "d") ?
<Regenaxer> See above
<Regenaxer> What are the rules?
<Regenaxer> why not '("a" "b" 1 2 3 " " "c" "d" " ") ?
<Regenaxer> or '("a" "b" 1 2 3 "c" "d" " ")
<Regenaxer> And what is the use case?
<aw-> rules are join the 3 lists and remove the leading/trailing spaces
<Regenaxer> yes, so 'clip'
<Regenaxer> ah, only first and last?
<aw-> yes
<aw-> leading whitespace on first item, trailing whitespace on last item
<Regenaxer> you want to clip the *result*
<aw-> yes exactly
<Regenaxer> So you first concat and then clip
<aw-> if there was a (ltrim), i could just do (ltrim (car L)) and (trim (cdr L))
<aw-> maybe
<Regenaxer> (clip (apply append '((" " "a" "b") (1 2 3) (" " "c" "d" " "))))
<Regenaxer> See? No use for rtrim
<Regenaxer> The typical case is always clip
<Regenaxer> trim is needed only for input garbage where the indentation is to preserve
<aw-> ok i will test your theory
<Regenaxer> Not really a theory :)
<Regenaxer> rather practical observation
<aw-> ok thanks!
<aw-> i should get back to code
<Regenaxer> Me too :)
alexshendi has quit [Read error: Connection reset by peer]
clacke[m] has quit [Ping timeout: 256 seconds]
rick42 has quit [Ping timeout: 260 seconds]
rick42 has joined #picolisp
clacke[m] has joined #picolisp
alexshendi has joined #picolisp
alexshendi has quit [Ping timeout: 240 seconds]
aw- has quit [Quit: Leaving.]
<beneroth> you're stubborn Regenaxer ;)
<beneroth> though most times rightly so
<beneroth> :)
<Regenaxer> agree, but which stubbornness do you refer to?
<beneroth> I'm not sure, haha
<Regenaxer> The 'clip' issue?
<beneroth> it's an example, yes. though I guess I think you are right
<Regenaxer> Thanks! :)
<beneroth> it's hard to draw the line: when should something be standard, and when should it be a use-case/app-specific DSL ? its difficult. especially when the core language of lisp is arguably just a few functions.
<Regenaxer> yep
<beneroth> important point is to try to explain the reasoning.
<beneroth> and not losing patience.
<Regenaxer> T
<beneroth> everyone believes he/she has the best reasons for their arguments. and I would say, in most cases in this group people try to argue quite some against themselves before bringing the issue to the table
<Regenaxer> Good to discuss such things here
<beneroth> you're strategy is to focus on the 90% (or maybe 99%) use cases from a radical practical point of view
<Regenaxer> yes, and practical means use cases, but sometimes also efficiency
<beneroth> T
<Regenaxer> ie. a seldom used function may be impossible or inefficient when written in Lisp
<beneroth> another approach is logical elegance. aw argued from that perspective in this case. (as I see it) you love logical elegance, but it takes second priority after practicability.
<beneroth> the elegance approach can lead to nice mental masturbation models with no real life use. e.g. XML, UML, etc.
<Regenaxer> hehe, yes
<beneroth> (I mainly mean about the fact that there people even built a theory where the thing itselfs fits into its own theory.. more or less completely.. more likely less, gödel etc)
<beneroth> though the too-practical approach can lead to very domain-specific idiosyncratic design, hard to understand or reuse when not coming from the same background/use cases
<beneroth> example.. hm.. maybe perl? :D
<beneroth> the fact that picolisp text IO cannot handle NULL in input I still find extremely inelegant... but I see your technical reasoning (haha, took me a while), no point to sacrifice efficiency in general case for a pretty unusual case
<beneroth> problem is one has to be aware of all this edgy use cases
<Regenaxer> Hmm, it can handle
<Regenaxer> it is not an IO problem
<Regenaxer> it is symbol internal implementation
<Regenaxer> symbols names
<Regenaxer> They *can* have a null byte, but it terminates the name
<beneroth> not with (till)
<Regenaxer> Exactly the same as in C
<beneroth> T
<Regenaxer> no as till returns symbols
<beneroth> hm. ok. you are right.
<Regenaxer> Zero is binary, so it must be handled with (rd)
<beneroth> one could argue the same should be valid for TAB and the other special whitespaces
<Regenaxer> No, all other chars can be part of symbol names
<Regenaxer> Remember, just as in C
<beneroth> I don't want to discuss that specific case, I don't think we missed any insights there (except me not formulating it technically correct)
<Regenaxer> The null byte is needed to terminate symbol names
<Regenaxer> Like in C ;)
<beneroth> just another example of your stubbornness. and.. I think your stubbornness was well placed in that case. arguably, if it is purposeful you can be convinced after a while :D
<beneroth> aye
<beneroth> and it makes sense. only other solution would be storing lengths everywhere.
<Regenaxer> It is not stubbornness in this case, there is simply no other way technically
<beneroth> and its a better solution than FORTRAN strings (fixed length à la C, but end is always padded with whitespaces)
<Regenaxer> Not a question of wanting or not wanting to implement
<beneroth> T
<Regenaxer> Yes, fixed length is the other design decision, also eg. in Pascal
<Regenaxer> This limit the max length
<beneroth> hm
<Regenaxer> in org. Pascal it was 1 byte count
<beneroth> you are right
<beneroth> I can't find even an infeasible alternative :D
<Regenaxer> So I decided against it. "Unlimiteness"
<Regenaxer> Well, a count of 8 bytes would do, but is a huge waste
<Regenaxer> 2 bytes limit to 65535 bytes
<Regenaxer> Oops, sorry, being called
<Regenaxer> Some duties :)
<Regenaxer> afp
<beneroth> bbl :)
alexshendi has joined #picolisp
orivej has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
jibanes has quit [Ping timeout: 240 seconds]
jibanes has joined #picolisp
<Regenaxer> ret
jibanes has quit [Ping timeout: 240 seconds]
jibanes has joined #picolisp
orivej has quit [Ping timeout: 265 seconds]
orivej has joined #picolisp
alexshendi has joined #picolisp
mario-goulart has quit [Remote host closed the connection]
mario-goulart has joined #picolisp
alexshendi has quit [Ping timeout: 250 seconds]
dtornabene has joined #picolisp
dtornabene_ has joined #picolisp
dtornabene has quit [Read error: Connection reset by peer]
dtornabene_ has quit [Ping timeout: 264 seconds]
sriram_ has quit [Ping timeout: 260 seconds]
reed has joined #picolisp
<reed> Hi all, is there a standard way to do Unix sockets on PicoLisp? I see that there's some documentation on websockets, but I'm looking for the local version. I.e. as if it were created with the "AF_LOCAL" keyword in C
orivej has quit [Ping timeout: 240 seconds]
orivej has joined #picolisp
alexshendi has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
reed has quit [Quit: Page closed]
mario-goulart has quit [Remote host closed the connection]
mario-goulart has joined #picolisp
joebo has quit [Ping timeout: 240 seconds]
joebo has joined #picolisp
alexshendi has joined #picolisp