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
[rg] has quit [Remote host closed the connection]
orivej has quit [Ping timeout: 245 seconds]
[rg] has joined #picolisp
jibanes has quit [Ping timeout: 258 seconds]
jibanes has joined #picolisp
<[rg]> so a string will evaluate to itself, and so will numbers
<[rg]> however the strings do not if in a list
<[rg]> why is that?
<[rg]> is it hard to distinguish the symbol type?
<Regenaxer> Hi [rg]
<[rg]> hello :)
<Regenaxer> Yes, a string is a symbol which happens to have itself in the value
<Regenaxer> With "in a list" you mean ("a" 2 3)?
<Regenaxer> "a" is not a function probably
<[rg]> yes
<[rg]> or even ("a")
<Regenaxer> right
<[rg]> also I notice commas can be used in integer lists
<Regenaxer> this tries to call a function
<[rg]> because a function is a list
<[rg]> right?
<[rg]> and lines from the repl are being evaluated
<Regenaxer> no
<Regenaxer> yes :)
<Regenaxer> : "a"
<Regenaxer> this evaluates "a"
<Regenaxer> : (foo "a")
<Regenaxer> this evaluates "a" and *calls 'foo'
<Regenaxer> Functions are called by recursively exaluating args, then calling the function
<Regenaxer> So if "a" is not a function it gives an error
<[rg]> i also notice the tail of a series of atoms is the only thing printed, say "A" "B" "d"
<Regenaxer> Try (setq "a" +) ("a" 3 4)
<[rg]> you get -> "d"
<[rg]> interesting, ill try that
<Regenaxer> The repl prints the result of the last expression
<Regenaxer> after evaluating them all
<[rg]> fair, yeah I see that
<[rg]> so now how do you get rid of this association, is it ===
<Regenaxer> which association?
<[rg]> oh nvm
<[rg]> i was speaking to (setq "a" +)
<Regenaxer> ah
<[rg]> but "a" is just another variable now
<Regenaxer> it is just a symbol
<[rg]> yeah thought it was the other way for some reason
<Regenaxer> now with the same *value* as the symbol '+'
<Regenaxer> The value of a symbol is called as a funtion if that symbol is in the CAR of a list being evaluated
<[rg]> is doc supposed to bring you to the link of the refernce page?
<Regenaxer> yes, (doc '+) works?
<Regenaxer> I assume you started as $ pil + ?
<[rg]> yeah
<[rg]> i must've mistyped earlier then
<Regenaxer> ok, just to make sure you have debug :)
<Regenaxer> 'doc' tries to find a browser
<Regenaxer> defaults to w3m iirc
<[rg]> yep, had to export BROWSER
<Regenaxer> Without browser you can also (help '+)
<Regenaxer> yes, good
<[rg]> was there ever any thought of brining the text up inside of pil?
<[rg]> not important just curious
<[rg]> i did use some languages that could do that, was pleasant
<Regenaxer> The text of the docs?
<[rg]> yeah
<Regenaxer> (help '+) just shows the text (?)
<[rg]> no it tried to bring up w3m
<[rg]> which I dont have
<Regenaxer> apt install w3m (?)
<[rg]> i assume it's not required
<[rg]> ok
<Regenaxer> Not needed if you exported BROWSER
<Regenaxer> or call (help '+ "firefox")
<[rg]> I did, and it worked with doc
<Regenaxer> ok
<[rg]> whats the mechanism behind it?
<Regenaxer> It uses 'call' to call an external program (the browser)
<Regenaxer> : (pp 'doc)
<[rg]> neato
<[rg]> ah rereading the stuff on commas
<[rg]> that does make sense now
<Regenaxer> The comma is a so-called read macro
<Regenaxer> I use it mostly for localizations
<[rg]> ok done reading for now, phew
<Regenaxer> :)
<[rg]> so picolisp being list based, everything is recurisve?
<Regenaxer> Not necessarily, but often it is natural
<[rg]> alright, lets see how long it will take me to make a function to print a polynomial string
<Regenaxer> ok
* [rg] hacks away
stacksmith has quit [Ping timeout: 246 seconds]
<[rg]> Regenaxer, what is used for c like format strings?
<Regenaxer> There is no such kind of format strings
<Regenaxer> You can easily print any format directly I would say
<Regenaxer> 'prin' or 'pack'
<[rg]> im not sure the right incantation to interleave
<[rg]> oh ok, ill try pack
<Regenaxer> For example, what would you like to format?
<Regenaxer> "a %d x" -> (prin "a " 123 " x")
<Regenaxer> to align numbers, check 'align' or 'pad'
<[rg]> space is necessary?
<Regenaxer> Depends how the output should look like
<[rg]> weird ok, my typing must just be bad right now
<Regenaxer> Can you show a short example of what you tried?
<[rg]> blast, history got lost becuase of scroll back
<[rg]> is there a history log?
<[rg]> yep history file ok
<Regenaxer> in the repl line editor? It is stored in ~/.pil/history
<[rg]> (prinl "a_"n"x^"n)
<[rg]> n was already defined
<Regenaxer> Ok, so you could write (prinl "a_" n "x^" n) for readability
<Regenaxer> Note that you should use 'N' instead of 'n' for local variables in general
<Regenaxer> (prinl "a_" N "x^" N)
<[rg]> ah, interesting
<Regenaxer> Or (prinl "a_" N "x^" N)
<Regenaxer> Whitespace between arguments does not matter
<[rg]> yes i normally value readability, just typing frantically lol
<Regenaxer> newlines, indentation etc
<Regenaxer> no problem :)
<Regenaxer> ah
<Regenaxer> '^' is a meta-char in strings
<Regenaxer> denotes control chars
<Regenaxer> So you need (prinl "a_" N "x\^" N)
<[rg]> oh ok
<[rg]> if I made my own prinl could I bypass that or is it a part of picolisp
<[rg]> how transient symbols are regonized i guess
<Regenaxer> yes, it is the reader
<Regenaxer> and the printer too
<Regenaxer> : (char 94)
<Regenaxer> -> "\^"
<Regenaxer> Same goes for the double quote of course "\""
<Regenaxer> Just like in C
<Regenaxer> doc/ref.html#transient-io
<[rg]> https://bpaste.net/show/56a6fa35d8f9 i'm segfaulting, any hints
<[rg]> guess this would be a good time to view the debugger also
<Regenaxer> Don't forget to change i and n to I and N
<Regenaxer> The problem is ((prin
<Regenaxer> you call the *result* of the 'prin' call as a function
<Regenaxer> Minor hint: (> i 0) should be (gt0 I)
<Regenaxer> Parents/indentation are also a bit strange?
<Regenaxer> Ah, no, I was confused by the ) ) )
<[rg]> neat
<Regenaxer> (if (and (> i 0) (< i n) (prin " + ") ) )
<[rg]> yeah the parens where messed up
<Regenaxer> It is better (and (gt0 I) (< I N) (prin " + "))
<Regenaxer> ie the 'if' is empty anyway
<[rg]> not sure why the spaces are there, im using emacs atm
<Regenaxer> In any case, very good for a first try!!!
<[rg]> ah cool, gt0
<[rg]> thanks :)
<Regenaxer> :)
<Regenaxer> (and (gt0 I) (< I N) ..) can be shortened
<Regenaxer> (> N I 0)
<Regenaxer> or (< 0 I N)
<[rg]> in the prompt "^J" gets displayed in the prompt ->
<[rg]> what does that mean?
<[rg]> oh woah
<Regenaxer> this is just the return value
<[rg]> cool
<Regenaxer> Just (prinl) prints a newline
<Regenaxer> I think no "^J" is needed
<[rg]> so < gets applied on the list
<[rg]> since prefix it works
<Regenaxer> Exactly
<[rg]> neat
<Regenaxer> After -> always the last result is printed
<Regenaxer> and 'for' returns the value of the *last* expression
<Regenaxer> I think the check (if (= i n) (prinl is not needed
<Regenaxer> Just call (prinl) *after* the for loop
<Regenaxer> I must be N then :)
<[rg]> can I reload in pil
<Regenaxer> yes
<Regenaxer> I have not tested, but I would write it as:
<Regenaxer> (de polynomial (N)
<Regenaxer> (for I N
<Regenaxer> "a_" I
<Regenaxer> (prin
<Regenaxer> "x\^" I
<Regenaxer> (and (< I N) " + ") ) )
<Regenaxer> (prinl) )
<Regenaxer> : (load "myfile.l")
<[rg]> so boolean expression like that serve as conditionals?
<[rg]> ok
<Regenaxer> The above uses the fact that (prin NIL) prints nothing
<Regenaxer> "" is NIL in PicoLisp
<Regenaxer> and (and (< I N) " + ") returns NIL at the end
<Regenaxer> you could also write (unless (= I N) " + ")
<Regenaxer> this returns also NIL
<Regenaxer> in the last iteration
<[rg]> clever
<Regenaxer> (and (< I N) is perhaps more clear
<[rg]> it is, thank you this was very insightful
<Regenaxer> :)
<[rg]> so recursively I would imagine I would just use a counting argument, but i see the rest being similar
<Regenaxer> OK, must go, bbl
<[rg]> c ya
<Nistur> mornin'
<[rg]> sup
<[rg]> is any effort expended to print NIL or ""
<Regenaxer> ret
<Regenaxer> Hi Nistur
<Regenaxer> There is no way to distinguish NIL from ""
<Regenaxer> '""' *is* NIL
<Regenaxer> You must (prin "\"\"")
[rg] has quit [Quit: Leaving]
<beneroth> hi
<Regenaxer> Moin beneroth
orivej has joined #picolisp
beneroth has quit [Quit: Verlassend]
[rg] has joined #picolisp
mtsd has joined #picolisp
groovy2shoes has quit [Quit: moritura te salutat]
ubLIX has joined #picolisp
ubLIX has quit [Quit: ubLIX]
[rg] has quit [Quit: Leaving]
mtsd has quit [Quit: leaving]
[rg] has joined #picolisp
stacksmith has joined #picolisp
<[rg]> why should this work, its interesting https://termbin.com/mxr4
<[rg]> this is the what i intended anyways https://termbin.com/mxr4
stacksmith has quit [Ping timeout: 258 seconds]
[rg] has quit [Quit: Leaving]
[rg] has joined #picolisp
[rg] has quit [Remote host closed the connection]
ubLIX has joined #picolisp