tooDumbToFleng has quit [Ping timeout: 240 seconds]
tooDumbToFleng has joined #picolisp
<razzy>
vip :r should re-read file from disk. yes?
<razzy>
it is not working.
razzy has quit [Ping timeout: 252 seconds]
tooDumbToFleng has quit [Quit: -a- Connection Timed Out]
tooDumbToFleng has joined #picolisp
tooDumbToFleng has quit [Quit: -a- Connection Timed Out]
tooDumbToFleng has joined #picolisp
schulze has quit [Ping timeout: 256 seconds]
tooDumbToFleng has quit [Quit: -a- Connection Timed Out]
tooDumbToFleng has joined #picolisp
tooDumbToFleng has quit [Quit: -a- Connection Timed Out]
tooDumbToFleng has joined #picolisp
tooDumbToFleng has quit [Quit: -a- Connection Timed Out]
tooDumbToFleng has joined #picolisp
tooDumbToFleng has quit [Quit: -a- Connection Timed Out]
tooDumbToFleng has joined #picolisp
tooDumbToFleng has quit [Quit: -a- Connection Timed Out]
tooDumbToFleng has joined #picolisp
razzy has joined #picolisp
<Regenaxer>
Hi razzy!
<Regenaxer>
:r reads in a file
<Regenaxer>
:r file.l
<Regenaxer>
to reload the current file, do :e
<Regenaxer>
:e is either with or without arguments
<Regenaxer>
:r always needs one arg
tooDumbToFleng has quit [Ping timeout: 240 seconds]
schulze has joined #picolisp
tooDumbToFleng has joined #picolisp
<razzy>
Hi Regenaxer Thank you. I do not see value of :r than.
<razzy>
now i see.
tooDumbToFleng has quit [Quit: -a- Connection Timed Out]
<Regenaxer>
👍
tooDumbToFleng has joined #picolisp
tooDumbToFleng has quit [Remote host closed the connection]
clacke has quit [Remote host closed the connection]
razzy has quit [Ping timeout: 256 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 240 seconds]
razzy has joined #picolisp
Hunar has joined #picolisp
<Hunar>
Hello :) question: If there was a list (setq A (1 2 3)) and I had a reference to it (setq R A) and wanted to replace the original list with this list (setq B (4 5 6)) while only having access to the reference R .. is this the only way? (set R (car B)) (con R (cdr B)) or there is a built in function
<Regenaxer>
Hi Hunar. It is not clear what you want to replace. The value of A is the first cell of the list
<Regenaxer>
and R too
<Regenaxer>
So (setq A ...) replaces the value with a *new* value
aw- has quit [Ping timeout: 240 seconds]
<Regenaxer>
or do you want to modify cells in the original list?
<Hunar>
A holds a list .. I want to replacet the list with a different list, while only having access to R but not A
<Regenaxer>
Perhaps draw a cell diagram?
<Regenaxer>
What "replace"?
<Regenaxer>
R and A hold the same cell
<Regenaxer>
so you can *modify* these cells
<Regenaxer>
or make a new list
<Hunar>
I can simply set the list in A with another list (setq A B) but I dont have access to it, I only have access to R ..
<Regenaxer>
But R *is* A, no?
<Regenaxer>
You did (setq R A)
<Hunar>
yes, but (setq R B) doesnt change A .. I want to change A without using A
<Regenaxer>
R and A are pointers to the same list
<Regenaxer>
You want to chage the cells *in* the list then
<Regenaxer>
(set (cdr A) 7)
<Regenaxer>
same as (set (cdr R) 7)
<Regenaxer>
Draw an cell diagram
<Hunar>
You mean drawing it for myself or to explain the question to you?
<Regenaxer>
Just for yourself
<Regenaxer>
Or just in your head
<Regenaxer>
the value cell points to (1 . (2 3))
<Regenaxer>
value of A
<Regenaxer>
and of R
<Regenaxer>
right?
<Hunar>
I did it in my head and already found the solution above (set R (car B)) (con R (cdr B)) this does exactly what I want.. I just want to know if there is a more direct way :)
<Regenaxer>
ok, so you modified the first cell
<Regenaxer>
in A and R
<Regenaxer>
But why?
<Hunar>
Let me give an example,
<Regenaxer>
good
<Hunar>
This comes up for me alot I loop over a list of lists (setq A '( (1 2 3) (4 5 6)) I loop over it with for (for I A ...) inside the loop I want to change the sublists in A but cant directly hence the problem.. I know I can change the for loop for a mapping function and make my life easier but its good to know other
<Hunar>
workarounds
<Regenaxer>
Changing the sublists in A should work directly
<Regenaxer>
(for A Lst (set A <anything>))
<Regenaxer>
eg
<Regenaxer>
(for A Lst (set A (cons 7 (cdar R))))
<Regenaxer>
replaces the first element in each list
<Hunar>
that works but the problem arises when In the loop I create a new list and I just want replace the current list with the newly created list
<Regenaxer>
R was nonsense above
<Regenaxer>
this:
<Regenaxer>
: (setq Lst '((1 2 3) (4 5 6)))
<Regenaxer>
-> ((1 2 3) (4 5 6))
<Regenaxer>
: (for A Lst (set A 7))
<Regenaxer>
: Lst
<Regenaxer>
-> 7
<Regenaxer>
-> ((7 2 3) (7 5 6))
<Regenaxer>
hmm, either you create a new list or you modify an existing list, but not both, right?
<Regenaxer>
If you want to replace the top list
<Regenaxer>
use (mapcar ...)
<Hunar>
yes, mapcar works without any problems
<Regenaxer>
yes, make a new list
<Regenaxer>
So I do not really understand the problem
<Regenaxer>
Either make a new list, or modify cells destructively
<Regenaxer>
both are ok depending on the situation
<Hunar>
I think I should stop :) my idea is silly and not practical anyways .. (setq Lst '((1 2 3) (4 5 6))) (for A Lst (set A (9 9 9))) my idea was to have Lst = ((9 9 9) (9 9 9)) after that loop .. I should just giveup on using (for) for that situation
<Regenaxer>
for is ok
<Regenaxer>
it is equivalent to other mappings
<Regenaxer>
So I would use 'for' here too
<Regenaxer>
(for A Lst (set A ... is goo n
<Regenaxer>
good
<Regenaxer>
destructively modifies all CARs in Lst
<Regenaxer>
With map it is slower (map '((A) (set A (9 9 9))) Lst)
<Regenaxer>
can also be
<Regenaxer>
(map set Lst '((9 9 9) .))
<Regenaxer>
this is faster
<Hunar>
:) thanks
<Regenaxer>
An EXPR like '((A) (set A ...)) is relatively slow
<Regenaxer>
calls, binds, unbinds A
<Regenaxer>
hmm, wrong above anyway :)
<Regenaxer>
Such constructs work only with mapc, mapcar etc.
<Regenaxer>
So 'for' is the best here
<Regenaxer>
fastest and shortest :)
<Hunar>
Today I tested this (de thing () (prinl A)) (let A 4 (thing)) I thought the function wouldn't find A :/ I was wrong .. I wasn't aware of that since other languages aren't like that .. but it makes alot of programs easier for me
<Regenaxer>
yeah, this is dynamic binding
<Regenaxer>
good sometimes, but also dangerous as we saw yesterday in your drawCanvas
<Regenaxer>
eg 'U' was bound at a higher level in 'http'
<Regenaxer>
If you write (de thing () (prinl A)) and then 'lint' it, you get a warning
<Regenaxer>
: (de thing () (prinl A))
<Regenaxer>
-> thing
<Regenaxer>
: (lint 'thing)
<Regenaxer>
-> ((bnd A))
<Regenaxer>
Means "please bind A"
<Regenaxer>
The convention for that is "_"
<Hunar>
Aha
<Regenaxer>
: (de _thing () (prinl A))
<Regenaxer>
-> _thing
<Regenaxer>
: (lint '_thing)
<Regenaxer>
-> NIL
<Regenaxer>
: (lintAll)
<Regenaxer>
-> ((thing (bnd A)))
<Regenaxer>
Just call lintAll from time to time
<Hunar>
I will :) I was searching through common lisp macro tutorials to see how can I do them in pil .. this dynamic binding made alot of the macros into a normal function
<Regenaxer>
Most of all FEXPRs can be used for the purpose macros are used in CL
<Hunar>
Yes :D
<Regenaxer>
I think I once wrote a
<Regenaxer>
CL-style 'do'
<Hunar>
yes, it's in the FAQ
<Regenaxer>
ah, yes
<Hunar>
but it was unreadable for my beginner eyes when I saw it
<Regenaxer>
well, for me too
<Regenaxer>
it does some variable binding
<Hunar>
Tried the above example in CL, it said (The variable A is unbound.) so pil IS the first language I learn with that feature
<Regenaxer>
also I don't remember now what a CL do* does ;)
<Hunar>
me too
<Regenaxer>
:)
<Regenaxer>
must go, bbl
Hunar has quit [Quit: Client closed]
<Regenaxer>
ret
tankf33der has quit [Quit: Ping timeout (120 seconds)]
tankf33der has joined #picolisp
<razzy>
I am missing save evaluation in vip. my naive code does not work # ("^E" (evCmd (eval (unless (fork) (msg (s-expr)) (bye))))) # Evaluate expression
<Regenaxer>
Yes, evaluating in child process
<Regenaxer>
It cannot modify data in current process, so somewhat limited
<Regenaxer>
You could catch errors
<Regenaxer>
(catch '("") (evCmd ...
<Regenaxer>
like the REPL in Vip does
<Regenaxer>
ah
<Regenaxer>
'evCmd' already does that, I forgot :)