<v_m_v>
It is taking list, lambda and accumulator and then process the list using lambdas
<Regenaxer>
Can you explain in short? I'm on the road walking
<Regenaxer>
ok
<Regenaxer>
Where is it needed?
<Regenaxer>
a short example?
<Regenaxer>
In any case this sounds like a compiler issue again, no?
<Regenaxer>
Normally you can do such things in Pil directly
<Regenaxer>
Without need of preprocessing
<v_m_v>
hmm you don't need to preprocess it. at the end you are getting accumulated result
<Regenaxer>
Example?
<v_m_v>
like (foldr 1 (*) '(1 2 3)) => 6
<Regenaxer>
Why not (apply * (1 2 3)) -> 6 ?
<Regenaxer>
(apply * (2 3) 1)
<v_m_v>
with fold you can make more complicated things.
<v_m_v>
it is like apply with custom accumulator behaviour
<Regenaxer>
I think in Pil you need 'let' then
<Regenaxer>
(let A 1 (for ...
<v_m_v>
i see. I can implement reduce and fold by myself.
<Regenaxer>
Yes, but where would you need reduce?
<v_m_v>
It is just simpler for me to use them (they are exists in almost all of the programming languages)
<v_m_v>
reduce is like a fold without the "first element"
<v_m_v>
for reduce the first element is the element from your list
<Regenaxer>
Example?
<Regenaxer>
Pil uses varargs in such cases
<Regenaxer>
So the function does it directly
<Regenaxer>
When is reduce really needed?
<v_m_v>
Hmmm ok. Password strength validation. You have a list of lambdas. Each of those lambdas is validationg password requirement ...one is validating lenght..the second one ..special character etc. Each of those validator is returning T/F
<v_m_v>
You can use reduce on such list with your password and get the final result
<v_m_v>
I know that you can do it in the imperative way ...with for loop etc
<Regenaxer>
would be a simple 'find' over a list of functions
<v_m_v>
Reduce just make it simpler.
<v_m_v>
I don't think so ...that you can use find for that case
<Regenaxer>
(find '((Fun) (not (Fun X))) (list of funs ...
<v_m_v>
I mean..you don't need reduce... Reduce is making the list reduction ... so it is helping you in some cases
<Regenaxer>
ok
<v_m_v>
It is also everywhere ...js, python, java...lisps, schemes
<Regenaxer>
I'm sure I would have implemented it if I ever needed
<v_m_v>
So it is easy for me to transport my code from one language to another.
<v_m_v>
you don't "need" it :) it is just making things easier to deal with
<v_m_v>
as a common concept between multiple languages. But I can easily implement it by myself :)
<Regenaxer>
With "need" I mean it gets shorter ;)
<v_m_v>
it is a part of "functional" programming I think. The basic concept in each functional programming book.
<v_m_v>
But once again. in PicoLisp it is just a couple of lines.
<v_m_v>
and then I can use it everywhere :D
<v_m_v>
So no worries :)
<Regenaxer>
But makes it slower
<v_m_v>
I don't think so.
<Regenaxer>
should be in kernel
<Regenaxer>
well, you have another layer of interpretation
<v_m_v>
Hmm in all of those languages abowe...reduce, fold etc are one of the fastest way of dealing with lists
<v_m_v>
oh right...I forgot about that:/
<v_m_v>
damn...
<v_m_v>
Hmm I can do it in Rust/C then ...and attach it to PIL
<Regenaxer>
I think the fastest is to do it directly
<Regenaxer>
Iterate funs etc
<Regenaxer>
I still don't see if reduce makes it simpler
<Regenaxer>
Can you do that with a 'reduced' expression?
<beneroth>
v_m_v, you are overthinking. "optimizations" from other languages mostly don't apply for picolisp
<Regenaxer>
exactly
<beneroth>
"most languages doing something" = either it's essential or sturgeons law applies
<Regenaxer>
Same with recursion. Recursing over a non-recursive data structure (a linear list) is the wrong approach
<Regenaxer>
Recursion is needed for trees
<beneroth>
T, finite trees.
<Regenaxer>
yep, hopefully ;)
<beneroth>
recursion is for laziness :P
<Regenaxer>
or academic books
<beneroth>
which have the goal to be clever. clever is bad code, unless strictly necessary. hell all code is bad code unless necessary.
<beneroth>
less code = less bugs = easier to change = easier to maintain.
<Regenaxer>
right
<Regenaxer>
And a loop is more clear in many cases
<beneroth>
v_m_v, I think the question you wrote with (begin ..) is that not just how picolisp functions work by default? returning last result?
<beneroth>
Regenaxer, nvm ;)
<Regenaxer>
Ah, the 'begin' question?
<Regenaxer>
no problem :)
<Regenaxer>
As I said, it is 'prog' in pil probably
<Regenaxer>
but very seldom needed in flow like above
<beneroth>
well kinda...
<beneroth>
aye
<Regenaxer>
'when' or 'unless' or 'cond'
<beneroth>
just do the actual thing instead of overhead
<Regenaxer>
T
<Regenaxer>
I notice most newcomers to Pil overuse 'if'
<Regenaxer>
I use 'if' *only* if I have if/else
<Regenaxer>
oherwise 'and' or 'when' is better
<Regenaxer>
In v_m_v's example there was (if (cond) (xxxx) NIL)
<Regenaxer>
the NIL is implied anyway
<Regenaxer>
(if (cond) (xxxx))
<Regenaxer>
so we do (and (cond) (xxxx))
<Regenaxer>
'if' has an implied 'prog' for the "else" part BTW
v_m_v has quit [Remote host closed the connection]
<beneroth>
Regenaxer, T
<Regenaxer>
Hmm, not very nice, posing lots of questions and then vanishing
calle has joined #picolisp
calle has quit [Ping timeout: 272 seconds]
calle has joined #picolisp
calle has quit [Ping timeout: 276 seconds]
<beneroth>
Regenaxer, aye
<Regenaxer>
;(
v_m_v has joined #picolisp
<v_m_v>
guys PIL would work normally on arm64 right?
<beneroth>
yes?
<beneroth>
it's used on android for years
calle has joined #picolisp
<v_m_v>
what is the reason behind (get (1 2 3 4) -2) and not getting NIL?
<v_m_v>
and nother question: random element from list :D
<Regenaxer>
v_m_v, negative indexes meaning CDRs are practical
<v_m_v>
CDRs?
<Regenaxer>
random elements? Look at @lib/simul.l
<Regenaxer>
yes
<Regenaxer>
: (get (1 2 3 4) -2)
<Regenaxer>
-> (3 4)
<Regenaxer>
v_m_v, please check the logs
<Regenaxer>
We talked a lot to you but you just disawpeared
<Regenaxer>
We don't want to waste our time, right?
<v_m_v>
oh sorry. I've been logged out. This is the biggest issue of IRC :/
<v_m_v>
Sometimes I am loosing some info
<Regenaxer>
all right :)
<v_m_v>
Hmmm I see now :)
<v_m_v>
Ok.. there is one more thing which I can not crack by myself....Objects. I know how I can create them in PIL. But is there anything like a "self" in PIL? I mean if I have method and in that method I would like to run other method from the same class how I can pass "self" there ?
<v_m_v>
Hmm I don't know If I am clear
<Regenaxer>
I think I understand
<Regenaxer>
it is the 'This' variable bound automatically
<Regenaxer>
Hmm, seems I'm talking into the wind. Anyway, tired. Will go to sleep. Good night! AFP
<v_m_v>
sorry...it is taking me some time to process everything what you are writing :D
<v_m_v>
I don't want to give you a feeling that I don't care....I am just trying to put all of that info into my queue :)
<v_m_v>
I know Mia blog :D To be honest I am a big fan...specially of her last topics. Task was also quite important for me.
<v_m_v>
There is a one thing which I think (in yours examples) could be not that optimal. You have removed my (let with Position (: position)
<v_m_v>
But witout it each time when I need something from position I have to make (: position) so in many iterations my solution should be a slighty faster right?
v_m_v has quit [Remote host closed the connection]
v_m_v has joined #picolisp
<v_m_v>
I've to change client...this one is disconnecting me to often :/