theruran has quit [Write error: Connection reset by peer]
theruran has joined #picolisp
_whitelogger has joined #picolisp
mabi has quit [*.net *.split]
Nistur has quit [*.net *.split]
Nistur has joined #picolisp
mabi has joined #picolisp
wineroots has joined #picolisp
peterhil has joined #picolisp
mtsd has joined #picolisp
mtsd has quit [Quit: Leaving]
mario-go` is now known as mario-goulart
mario-goulart has quit [Changing host]
mario-goulart has joined #picolisp
razzy has quit [Ping timeout: 240 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
<razzy>
I like to be light and mobile. I use small BT keyboard with phone. I do not have few weeks to spare learning penti :]
<razzy>
Good day to all! :]
beneroth has joined #picolisp
<Regenaxer>
Hi razzy, beneroth!
<beneroth>
Ahoy Regenaxer, razzy :)
<Regenaxer>
:)
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 256 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 245 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 256 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 250 seconds]
hunar has joined #picolisp
<hunar>
Hello everyone :D
<Regenaxer>
Hi hunar! o/
<hunar>
I'm trying to create a circular list like this ("a" "b" "c" .) but like this "abc" I tried (circ (chop "abc")) but it makes (("a" "b" "c") .) instead of ("a" "b" "c" .) how can i do that
<Regenaxer>
(apply circ (chop "abc"))
<hunar>
Oh, that was easy :) thanks
<Regenaxer>
"manually" it can be done too :)
<Regenaxer>
(and (chop "abc") (con (tail 1 @) @))
<hunar>
(setq a (1 2) b (3 4))
<hunar>
(con (tail 1 a) b)
<hunar>
(con (tail 1 b) a)
<hunar>
I thought this would do something bad :D
<Regenaxer>
:)
<hunar>
Is there an overhead if made a LARGE list circular this way? => a=bigList (con (tail 1 a) a)
<Regenaxer>
Not too bad. The list is traversed once though
<Regenaxer>
Perhaps better than (apply circ L) cause 'apply' is expensive
<Regenaxer>
'con' is very fast, a single memory store
<Regenaxer>
only 'tail'
<hunar>
Is there a function to un-list :) I made this now `'(circ ~(chop "abc")) how efficient is that?
<Regenaxer>
Well, this is not useful in a function, as it is a read-macro
<Regenaxer>
You mean to un-circ?
<hunar>
I mean something that turns (1 2 3) into 1 2 3
<Regenaxer>
returning three items?
<Regenaxer>
You better operate on the list with mapping funs or so (?N
<Regenaxer>
)
<hunar>
Not three, circ takes arguments like this (circ 'a 'b 'c) but not like this (circ '(a b c)) .. so something like this (circ (unlist (list a b c))) which makes (circ 'a 'b 'c)
<Regenaxer>
that's what apply does
<hunar>
Oh
<Regenaxer>
(apply + (1 2 3)) is (+ 1 2 3)
<beneroth>
hey hunar :)
<hunar>
Hi beneroth :)
<Regenaxer>
Another option is (eval (cons 'circ Lst)) but it somehow feels ugly
<hunar>
I thought (apply a b) would call function a on every single b and (+ 1 2 3) is more efficient that (apply + (1 2 3))
<Regenaxer>
yes, (+ 1 2 3) is more efficient
<Regenaxer>
apply builds a stack structure and has function call overhead
<Regenaxer>
(apply a b) does as you say, if 'b' contains a list
<Regenaxer>
'b' is evaluated, so it gives (apply a (1 2 3))
<hunar>
But... how about my previous code, this doesn't have the overhead right? `'(+ ~(1 2 3))
<Regenaxer>
yes, that's fine, but not very useful as it oses a constant list
<Regenaxer>
so you can write directly (+ 1 2 3)
<Regenaxer>
and `' is strange
<Regenaxer>
not needed
<Regenaxer>
(+ ~(1 2 3)) is *read* as (+ 1 2 3)
<beneroth>
Regenaxer, how does (eval) overhead compare to (apply) ? I'd think the list building effort (before calling them) is about similar, maybe a bit more for (eval) ?
<Regenaxer>
'eval' has no overhead
<beneroth>
I've built real progs/expressions just using (make) and then calling (eval) on them in the past
<Regenaxer>
(eval (cons '+ has only a single cons
<Regenaxer>
then eval is the normal evaluation
<beneroth>
I guess my current approach would be using (apply) for smaller stuff and (make)+(eval) if I really need to do bigger blocks of meta/generative programming - when other ways is really not feasible for some reason
<beneroth>
though I tend more to using interpreter-fexpr and DSLs now
<Regenaxer>
vs (bench 99999999 (apply + (1 2 3)))
<hunar>
(it oses a constant list) I don't understand this fully :/ would this work if the list was constant (setq a 1 b 2 c 3) `'(+ ~(list a b c)) -> 6
<Regenaxer>
Well, ~ is handled at read time
<beneroth>
hunar, ~ and `backquote are evaluated during PARSING, so only once when the source code is read (or your repl input is parsed)
<beneroth>
similiar (from user perspective) to a precompiler in traditional compiling
<hunar>
Can you provide an example where (apply + (list a b c)) would work but `'(+ ~(list a b c)) wouldn't
<beneroth>
modifying the source code, not the program
<Regenaxer>
(apply + (list a b c)) makes no sense
<beneroth>
hunar, whenever the symbols a, b, c are not defined or should change
<Regenaxer>
it is the same as (+ a b c)
<Regenaxer>
hunar, think about read-time vs. eval-time
<beneroth>
with parsing I meant the READ step in R.E.P.L.
<Regenaxer>
T
<beneroth>
REPL: 1. Read (parse the source code from file, or from interactive terminal), which translates the text code into a binary representation (AST) 2. Evaluate (execute the program) 3. Print the results (the last/return value) 4. Loop: start again at 1.
<beneroth>
in step 1. READ the text code is translated into binary representation (cells and pointers), but the structure and content of the code is not changed at all. A PicoLisp program in RAM (memory) is exactly the same as it is written in the source code. EXCEPT for manipulations done by read macros (backquote, tilde, scalar number parsing).
<beneroth>
the reader in step 1. is a small programm which parses the input source code, and stops whenever it finds a read macro, reads+evaluates the whole read-macro-expression, and takes that result than as source code to continue
<beneroth>
so if you have a source code file with the content: (prinl "hello " `(pack "hu" "nar"))
<beneroth>
it's like taking that file and producing a new file: (prinl "hello " "hunar")
<beneroth>
and then put that file into picolisp interpreter
<beneroth>
hunar, is this explanation understandable?
<hunar>
Sorry my replies are delayed, i'm not home
<beneroth>
kk np :)
<hunar>
I understand now :)
<Regenaxer>
In summary, I would not worry and use 'apply'
hunar has quit [Ping timeout: 256 seconds]
razzy has joined #picolisp
hunar has joined #picolisp
<hunar>
:)
<Regenaxer>
'apply' is the very standard. It is in every Lisp
<Regenaxer>
And Lisp itself is defined in terms of apply
<Regenaxer>
i.e. arguments are 'eval'uated, then the function is applied
<Regenaxer>
a function call is (apply fun (mapcar apply Args)) in theory
<Regenaxer>
not in reality, would be too much overhead
<beneroth>
hunar, great :)
<hunar>
I wanted to make an ASCII Mandelbrot without looking at the rosetta code, I'm not happy with the result, its very dense https://pastebin.com/LcvpM125
<beneroth>
wow, not bad though
<hunar>
Thanks :D
<hunar>
If you wanted to zoom, you can change the xrange -2. 1. and yrange 1.2 1.2 ... for example -2. -1. and -0.4 0.4
<Regenaxer>
Was out. Cool, now looking at the code
<hunar>
The more critiques I get, the more I learn :D
<Regenaxer>
:)
<Regenaxer>
I see only minor details so far, lower case
<Regenaxer>
and indentation a little ;)
<hunar>
Yeah, I haven't trained my mind to use those naming rules yet ;/
<Regenaxer>
Just a style issoe
<Regenaxer>
issue
<hunar>
The indentation is Vip's comma :)
<Regenaxer>
logically it looks good
<hunar>
Really :o
<Regenaxer>
not the final 'for' loop
<Regenaxer>
the last (prinl) is too much indented :)
<Regenaxer>
The code itself looks very good!
<hunar>
I wanted to get the iteration variable when the loop finishes
<Regenaxer>
I cannot check the correctness atm
<hunar>
I think I did a small edit on notepad and it broke the indentation
<Regenaxer>
I see
<Regenaxer>
If you put the var at the end of the body, it will be returned
<Regenaxer>
Which var do you mean?
<Regenaxer>
'it'?
<hunar>
yes
<hunar>
(it) value when i break out of the loop
<Regenaxer>
It is here: (T (or (>= It 100) ... ?
<hunar>
Yes, I wanted to know at what it(eration) did i exit the for loop, is there a better way that i can use?
<Regenaxer>
I think this is the best way
<hunar>
Nice :D
<Regenaxer>
Exit with T and return the value
<hunar>
what is the equivalent of CL's let*
<hunar>
Oh, i should have tried before asking
<Regenaxer>
Pil's let is in fact CL' let*
clacke has joined #picolisp
<hunar>
Pil's let behaves like CL's let*
<Regenaxer>
yes
<Regenaxer>
there is no immediately binding let
<hunar>
Thanks :D I'll be going home now :)
hunar has quit [Quit: Client closed]
wineroots has quit [Remote host closed the connection]
clacke has quit [Remote host closed the connection]
<beneroth>
Regenaxer, what is CL's (let) doing?
<beneroth>
not evaluating?
<Regenaxer>
I think it binds all symbols simultaneously
<beneroth>
ah, not ordered
<Regenaxer>
like in function calls
<Regenaxer>
the same moment
<beneroth>
yeah I often make use of the ordered bindings in pil let
<Regenaxer>
yes, me too
<Regenaxer>
I never missed the other way
<beneroth>
T
<Regenaxer>
In fun calls it is critical
<Regenaxer>
(de f (A B) ...) (f (setq A 7) 8))
<Regenaxer>
this would confuse
<Regenaxer>
no
<beneroth>
it's the nicer/shorter variant of having a whole block of only variable assignments in other languages.. I mean they are still there, but just in the first parameter/list of (let), I find this elegant
<Regenaxer>
(f 7 (setq A 8))
<beneroth>
alternative would be blocks of a single (or multiple) setq calls
<Regenaxer>
so with F8 you see the size of the current expression
aw- has quit [Ping timeout: 240 seconds]
<hunar>
I initially used the REPL, but it doesn't get all the previous commands if i press (up arrow) so i usually write everything in one line to make testing faster
<Regenaxer>
Makes sense
<Regenaxer>
You could paste the line into Vip then and call pilPretty