Re: Stuck at PLEAC example

2018-06-10 Thread Arie van Wingerden
So I guess that the possibility of using This as a formal parameter is a
goodie associated with dynamic scoping, which I am not (yet) really used to
..

It opens a few doors. Nice!

Op zo 10 jun. 2018 18:20 schreef Arie van Wingerden :

> ​Hi Alex,
> ​
> ​
> > I would do it this way:
> >
> >(setq Employees '(emp1 emp2 emp3 emp4 emp5))
>
> OK. You don't use the values as names, but the properties, because you'd
> like to refer to (: name) in the 'prinl'.
> Got it.
>
> >(mapc put
> >   Employees
> >   '(name .)
> >   '("Abel" "Jones" "Millner" "Noles" "Zaphod") )
> >
> >(mapc put
> >   Employees
> >   '(category .)
> >   '(engineer cook teacher engineer vicar) )
>
> Agreed. Much less elaborate.
>
> >
> >(mapc show Employees)
>
> Nice and easy :)
>
> >
> >(with
> >   (find
> >  '((This) (== 'engineer (: category)))
> >  Employees )
> >   (prinl "Highest paid engineer is: " (: name))  )
>
>
> ​M
> aybe it would more appropriate t​o ​​change "Highest paid engineer​"​​ to
> "First engineer found"?​
>
> T
> ​he
> formal parameter
> ​ ​
> 'This' boggled my mind for a few minutes, but then it made sense :)
> Very nice trick indeed!​
>
> Thx,
>Arie
>
>   ​
>


Re: Stuck at PLEAC example

2018-06-10 Thread Arie van Wingerden
???

I can do:

: (get (car Employees) 'category)
-> engineer

: (show (car Employees))
emp1 NIL
   category engineer
   name "Abel"
-> emp1

which just works fine for me!

2018-06-10 17:43 GMT+02:00 Johann-Tobias Schäg :

>
> : (put emp1 'category 'engineer)
> -> engineer
> : (setq Employees '(emp1 emp2 emp3 emp4 emp5))
> -> (emp1 emp2 emp3 emp4 emp5)
> : (get emp1 'category)
> -> engineer
> : (car Employees)
> -> emp1
> : (get (car Employees) 'category)
> -> NIL
> (get `(car Employees) 'category) ## Bad idea in a general use, but fine
> for testing.
> -> engineer
> : (get (car Employees) 'category)
> -> NIL
> : (show (car Employees))
> emp1 NIL
> -> emp1
> : (show emp1)
> NIL NIL
>category engineer
> -> NIL
>
> If you can wrap your head around that behavior it will make sense.
> *Von:* johtob...@gmail.com
> *Gesendet:* 10. Juni 2018 5:33 nachm.
> *An:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> Also while pointer equality '== might be fine in this case '= makes more
> sense to me
>
> *Von:* johtob...@gmail.com
> *Gesendet:* 10. Juni 2018 5:31 nachm.
> *An:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> You are right. But that does not change the fact that your code will
> misbehave if you do not define a name.
> 2. You did not mentioned mention how it does misbehavior so i assumed.
>
> *Von:* xapw...@gmail.com
> *Gesendet:* 10. Juni 2018 5:25 nachm.
> *An:* picolisp@software-lab.de
> *Antworten:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> Hi Johann,
>
> I think that is not correct.
>
> In the first place I think I don't need a name property. Only the
> 'category!
>
> In the second place: (get 'name emp1) will ALWAYS return NIL, because the
> function call is incorrect.
> It should be: (get emp1 'name)
>
> In my examples this works ok:
> : (put emp1 'category 'engineer)
> -> engineer
> : (get emp1 'category)
> -> engineer
>
> Also this works:
> : (with emp1
>  (prinl (: category)))
> engineer
> -> engineer
>
> Best,
>Arie
>
> 2018-06-10 16:14 GMT+02:00 Johann-Tobias Schäg :
>
>>
>>
>> The first problem is that all your employees have no 'name property. (
>> get 'name emp1) -> NIL
>> But emp1 -> "Abel"
>>
>> But there is something else rotten. I can not spot. But try to get (with
>> 'emp1 (prinl (: name))) running first
>>
>> Regarding your 'This question:
>>  https://software-lab.de/doc/refT.html#This
>>
>>
>> *Von:* xapw...@gmail.com
>> *Gesendet:* 10. Juni 2018 2:20 nachm.
>> *An:* picolisp@software-lab.de
>> *Antworten:* picolisp@software-lab.de
>> *Betreff:* Stuck at PLEAC example
>>
>> Hi Alex,
>>
>> I am now working on the "Arrays" section at "Find First Element that
>> passes a Test".
>>
>> Your example:
>>(with
>>   (find
>>  '((This) (== 'engineer (: category)))
>>  Employees )
>>   (prinl "Highest paid engineer is: " (: name))  )
>>
>> This won't work of course, so I created a few things:
>>: (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5
>> "Zaphod")
>>-> "Zaphod"
>>
>>: (put emp1 'category 'engineer)
>>-> engineer
>>
>>: (put emp2 'category 'cook)
>>-> cook
>>
>>: (put emp3 'category 'teacher)
>>-> teacher
>>
>>: (put emp4 'category 'engineer)
>>-> engineer
>>
>>: (put emp5 'category 'vicar)
>>-> vicar
>>
>>: (setq Employees '(emp1 emp2 emp3 emp4 emp5))
>>-> (emp1 emp2 emp3 emp4 emp5)
>>
>> I guessed that this list Employees would be OK to feed 'find';
>> however, from the ref docs of 'with' I do not grasp how I should get this
>> to work.
>>
>> Also, the function used by 'find' has a formal parameter named This. Is
>> this the PicoLisp special variable, or just a name for a formal parameter?
>>
>> Please give a complete example!
>>
>> What I experience now is exactly why I think that there should be more
>> and better approachable docs.
>>
>> I think the reference should either be expanded by more comprehensive
>> examples + explanations, or otherwise I'll try and do that later in the
>> Wiki where I started the new section (with now only the 'de' example).
>>
>> I feel you, because it is all "in your head", but B2B a.k.a.
>> brain-2-brain is not yet possible, regrettably :)
>>
>> Seeing all this stuff i am convinced that PicoLisp also could have been
>> named YottaLisp, because of the sheer amount of possibilities hidden below
>> the surface :)
>>
>> Best,
>>Arie
>>
>
>


Re: Stuck at PLEAC example

2018-06-10 Thread Arie van Wingerden
Pls see previous reply.
I don't see the need for eval here ...

2018-06-10 18:05 GMT+02:00 Johann-Tobias Schäg :

> The solution to the puzzle:
> (get (eval (car Employees)) 'category)
> -> engineer
>
> Your list contain named symbols called emp1, ... , emp5
> You associate the properties with emp1 in the global binding.
> But find looks for a symbol which contains the attribute 'category. But
> none of the symbols in the list do.
> what you expected that find would do is take a thing, and if it is a
> symbol look in the global binding what it means there and look up in that
> definition for 'category)
>
> Regenaxer's approach is:
> Make a list of named symbols and put the properties into the symbols of
> the list.
> after Regenaxer's code ran (get emp2 'name) should
> be NIL because why should the global binding care that some named symbol
> which is not part of it got changed?
>
>
> *Von:* johtob...@gmail.com
> *Gesendet:* 10. Juni 2018 5:43 nachm.
> *An:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
>
> : (put emp1 'category 'engineer)
> -> engineer
> : (setq Employees '(emp1 emp2 emp3 emp4 emp5))
> -> (emp1 emp2 emp3 emp4 emp5)
> : (get emp1 'category)
> -> engineer
> : (car Employees)
> -> emp1
> : (get (car Employees) 'category)
> -> NIL
> (get `(car Employees) 'category) ## Bad idea in a general use, but fine
> for testing.
> -> engineer
> : (get (car Employees) 'category)
> -> NIL
> : (show (car Employees))
> emp1 NIL
> -> emp1
> : (show emp1)
> NIL NIL
>category engineer
> -> NIL
>
> If you can wrap your head around that behavior it will make sense.
> *Von:* johtob...@gmail.com
> *Gesendet:* 10. Juni 2018 5:33 nachm.
> *An:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> Also while pointer equality '== might be fine in this case '= makes more
> sense to me
>
> *Von:* johtob...@gmail.com
> *Gesendet:* 10. Juni 2018 5:31 nachm.
> *An:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> You are right. But that does not change the fact that your code will
> misbehave if you do not define a name.
> 2. You did not mentioned mention how it does misbehavior so i assumed.
>
> *Von:* xapw...@gmail.com
> *Gesendet:* 10. Juni 2018 5:25 nachm.
> *An:* picolisp@software-lab.de
> *Antworten:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> Hi Johann,
>
> I think that is not correct.
>
> In the first place I think I don't need a name property. Only the
> 'category!
>
> In the second place: (get 'name emp1) will ALWAYS return NIL, because the
> function call is incorrect.
> It should be: (get emp1 'name)
>
> In my examples this works ok:
> : (put emp1 'category 'engineer)
> -> engineer
> : (get emp1 'category)
> -> engineer
>
> Also this works:
> : (with emp1
>  (prinl (: category)))
> engineer
> -> engineer
>
> Best,
>Arie
>
> 2018-06-10 16:14 GMT+02:00 Johann-Tobias Schäg :
>
>>
>>
>> The first problem is that all your employees have no 'name property. (
>> get 'name emp1) -> NIL
>> But emp1 -> "Abel"
>>
>> But there is something else rotten. I can not spot. But try to get (with
>> 'emp1 (prinl (: name))) running first
>>
>> Regarding your 'This question:
>>  https://software-lab.de/doc/refT.html#This
>>
>>
>> *Von:* xapw...@gmail.com
>> *Gesendet:* 10. Juni 2018 2:20 nachm.
>> *An:* picolisp@software-lab.de
>> *Antworten:* picolisp@software-lab.de
>> *Betreff:* Stuck at PLEAC example
>>
>> Hi Alex,
>>
>> I am now working on the "Arrays" section at "Find First Element that
>> passes a Test".
>>
>> Your example:
>>(with
>>   (find
>>  '((This) (== 'engineer (: category)))
>>  Employees )
>>   (prinl "Highest paid engineer is: " (: name))  )
>>
>> This won't work of course, so I created a few things:
>>: (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5
>> "Zaphod")
>>-> "Zaphod"
>>
>>: (put emp1 'category 'engineer)
>>-> engineer
>>
>>: (put emp2 'category 'cook)
>>-> cook
>>
>>: (put emp3 'category 'teacher)
>>-> teacher
>>
>>: (put emp4 'category 'engineer)
>>-> engineer
>>
>>: (put emp5 'category 'vicar)
>>-> vicar
>>
>>: (setq Employees '(emp1 emp2 emp3 emp4 e

Re: Stuck at PLEAC example

2018-06-10 Thread Arie van Wingerden
Hi Johann,

you are right!
In my reply to Alex I explicitly tell about that :)

Thx,
   Arie

2018-06-10 17:31 GMT+02:00 Johann-Tobias Schäg :

> You are right. But that does not change the fact that your code will
> misbehave if you do not define a name.
> 2. You did not mentioned mention how it does misbehavior so i assumed.
>
> *Von:* xapw...@gmail.com
> *Gesendet:* 10. Juni 2018 5:25 nachm.
> *An:* picolisp@software-lab.de
> *Antworten:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> Hi Johann,
>
> I think that is not correct.
>
> In the first place I think I don't need a name property. Only the
> 'category!
>
> In the second place: (get 'name emp1) will ALWAYS return NIL, because the
> function call is incorrect.
> It should be: (get emp1 'name)
>
> In my examples this works ok:
> : (put emp1 'category 'engineer)
> -> engineer
> : (get emp1 'category)
> -> engineer
>
> Also this works:
> : (with emp1
>  (prinl (: category)))
> engineer
> -> engineer
>
> Best,
>Arie
>
> 2018-06-10 16:14 GMT+02:00 Johann-Tobias Schäg :
>
>>
>>
>> The first problem is that all your employees have no 'name property. (
>> get 'name emp1) -> NIL
>> But emp1 -> "Abel"
>>
>> But there is something else rotten. I can not spot. But try to get (with
>> 'emp1 (prinl (: name))) running first
>>
>> Regarding your 'This question:
>>  https://software-lab.de/doc/refT.html#This
>>
>>
>> *Von:* xapw...@gmail.com
>> *Gesendet:* 10. Juni 2018 2:20 nachm.
>> *An:* picolisp@software-lab.de
>> *Antworten:* picolisp@software-lab.de
>> *Betreff:* Stuck at PLEAC example
>>
>> Hi Alex,
>>
>> I am now working on the "Arrays" section at "Find First Element that
>> passes a Test".
>>
>> Your example:
>>(with
>>   (find
>>  '((This) (== 'engineer (: category)))
>>  Employees )
>>   (prinl "Highest paid engineer is: " (: name))  )
>>
>> This won't work of course, so I created a few things:
>>: (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5
>> "Zaphod")
>>-> "Zaphod"
>>
>>: (put emp1 'category 'engineer)
>>-> engineer
>>
>>: (put emp2 'category 'cook)
>>-> cook
>>
>>: (put emp3 'category 'teacher)
>>-> teacher
>>
>>: (put emp4 'category 'engineer)
>>-> engineer
>>
>>: (put emp5 'category 'vicar)
>>-> vicar
>>
>>: (setq Employees '(emp1 emp2 emp3 emp4 emp5))
>>-> (emp1 emp2 emp3 emp4 emp5)
>>
>> I guessed that this list Employees would be OK to feed 'find';
>> however, from the ref docs of 'with' I do not grasp how I should get this
>> to work.
>>
>> Also, the function used by 'find' has a formal parameter named This. Is
>> this the PicoLisp special variable, or just a name for a formal parameter?
>>
>> Please give a complete example!
>>
>> What I experience now is exactly why I think that there should be more
>> and better approachable docs.
>>
>> I think the reference should either be expanded by more comprehensive
>> examples + explanations, or otherwise I'll try and do that later in the
>> Wiki where I started the new section (with now only the 'de' example).
>>
>> I feel you, because it is all "in your head", but B2B a.k.a.
>> brain-2-brain is not yet possible, regrettably :)
>>
>> Seeing all this stuff i am convinced that PicoLisp also could have been
>> named YottaLisp, because of the sheer amount of possibilities hidden below
>> the surface :)
>>
>> Best,
>>Arie
>>
>
>


Re: Stuck at PLEAC example

2018-06-10 Thread Arie van Wingerden
Hi again,

well, the master himself created the original example, so ...
Also, I assume that this comparisopn might be a little bit faster, because
more specific?

Thx,
   Arie

2018-06-10 17:33 GMT+02:00 Johann-Tobias Schäg :

> Also while pointer equality '== might be fine in this case '= makes more
> sense to me
>
> *Von:* johtob...@gmail.com
> *Gesendet:* 10. Juni 2018 5:31 nachm.
> *An:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> You are right. But that does not change the fact that your code will
> misbehave if you do not define a name.
> 2. You did not mentioned mention how it does misbehavior so i assumed.
>
> *Von:* xapw...@gmail.com
> *Gesendet:* 10. Juni 2018 5:25 nachm.
> *An:* picolisp@software-lab.de
> *Antworten:* picolisp@software-lab.de
> *Betreff:* Re: Stuck at PLEAC example
>
> Hi Johann,
>
> I think that is not correct.
>
> In the first place I think I don't need a name property. Only the
> 'category!
>
> In the second place: (get 'name emp1) will ALWAYS return NIL, because the
> function call is incorrect.
> It should be: (get emp1 'name)
>
> In my examples this works ok:
> : (put emp1 'category 'engineer)
> -> engineer
> : (get emp1 'category)
> -> engineer
>
> Also this works:
> : (with emp1
>  (prinl (: category)))
> engineer
> -> engineer
>
> Best,
>Arie
>
> 2018-06-10 16:14 GMT+02:00 Johann-Tobias Schäg :
>
>>
>>
>> The first problem is that all your employees have no 'name property. (
>> get 'name emp1) -> NIL
>> But emp1 -> "Abel"
>>
>> But there is something else rotten. I can not spot. But try to get (with
>> 'emp1 (prinl (: name))) running first
>>
>> Regarding your 'This question:
>>  https://software-lab.de/doc/refT.html#This
>>
>>
>> *Von:* xapw...@gmail.com
>> *Gesendet:* 10. Juni 2018 2:20 nachm.
>> *An:* picolisp@software-lab.de
>> *Antworten:* picolisp@software-lab.de
>> *Betreff:* Stuck at PLEAC example
>>
>> Hi Alex,
>>
>> I am now working on the "Arrays" section at "Find First Element that
>> passes a Test".
>>
>> Your example:
>>(with
>>   (find
>>  '((This) (== 'engineer (: category)))
>>  Employees )
>>   (prinl "Highest paid engineer is: " (: name))  )
>>
>> This won't work of course, so I created a few things:
>>: (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5
>> "Zaphod")
>>-> "Zaphod"
>>
>>: (put emp1 'category 'engineer)
>>-> engineer
>>
>>: (put emp2 'category 'cook)
>>-> cook
>>
>>: (put emp3 'category 'teacher)
>>-> teacher
>>
>>: (put emp4 'category 'engineer)
>>-> engineer
>>
>>: (put emp5 'category 'vicar)
>>-> vicar
>>
>>: (setq Employees '(emp1 emp2 emp3 emp4 emp5))
>>-> (emp1 emp2 emp3 emp4 emp5)
>>
>> I guessed that this list Employees would be OK to feed 'find';
>> however, from the ref docs of 'with' I do not grasp how I should get this
>> to work.
>>
>> Also, the function used by 'find' has a formal parameter named This. Is
>> this the PicoLisp special variable, or just a name for a formal parameter?
>>
>> Please give a complete example!
>>
>> What I experience now is exactly why I think that there should be more
>> and better approachable docs.
>>
>> I think the reference should either be expanded by more comprehensive
>> examples + explanations, or otherwise I'll try and do that later in the
>> Wiki where I started the new section (with now only the 'de' example).
>>
>> I feel you, because it is all "in your head", but B2B a.k.a.
>> brain-2-brain is not yet possible, regrettably :)
>>
>> Seeing all this stuff i am convinced that PicoLisp also could have been
>> named YottaLisp, because of the sheer amount of possibilities hidden below
>> the surface :)
>>
>> Best,
>>Arie
>>
>
>


Re: Stuck at PLEAC example

2018-06-10 Thread Arie van Wingerden
​Hi Alex,
​
​
> I would do it this way:
>
>(setq Employees '(emp1 emp2 emp3 emp4 emp5))

OK. You don't use the values as names, but the properties, because you'd
like to refer to (: name) in the 'prinl'.
Got it.

>(mapc put
>   Employees
>   '(name .)
>   '("Abel" "Jones" "Millner" "Noles" "Zaphod") )
>
>(mapc put
>   Employees
>   '(category .)
>   '(engineer cook teacher engineer vicar) )

Agreed. Much less elaborate.

>
>(mapc show Employees)

Nice and easy :)

>
>(with
>   (find
>  '((This) (== 'engineer (: category)))
>  Employees )
>   (prinl "Highest paid engineer is: " (: name))  )


​M
aybe it would more appropriate t​o ​​change "Highest paid engineer​"​​ to
"First engineer found"?​

T
​he
formal parameter
​ ​
'This' boggled my mind for a few minutes, but then it made sense :)
Very nice trick indeed!​

Thx,
   Arie

  ​


Re: Stuck at PLEAC example

2018-06-10 Thread Johann-Tobias Schäg
 : (put emp1 'category 'engineer)-> engineer: (setq Employees '(emp1 emp2 emp3 emp4 emp5))-> (emp1 emp2 emp3 emp4 emp5): (get emp1 'category)-> engineer: (car Employees)-> emp1: (get (car Employees) 'category)-> NIL(get `(car Employees) 'category) ## Bad idea in a general use, but fine for testing.-> engineer: (get (car Employees) 'category)-> NIL: (show (car Employees))emp1 NIL-> emp1: (show emp1)NIL NIL   category engineer-> NILIf you can wrap your head around that behavior it will make sense.Von: johtob...@gmail.comGesendet: 10. Juni 2018 5:33 nachm.An: picolisp@software-lab.deBetreff: Re: Stuck at PLEAC exampleAlso while pointer equality '== might be fine in this case '= makes more sense to me   Von:  johtob...@gmail.comGesendet: 10. Juni 2018 5:31 nachm.An:  picolisp@software-lab.deBetreff: Re: Stuck at PLEAC exampleYou are right. But that does not change the fact that your code will misbehave if you do not define a name.2. You did not mentioned mention how it does misbehavior so i assumed.   Von:  xapw...@gmail.comGesendet: 10. Juni 2018 5:25 nachm.An:  picolisp@software-lab.deAntworten:  picolisp@software-lab.deBetreff: Re: Stuck at PLEAC example  Hi Johann,I think that is not correct.In the first place I think I don't need a name property. Only the 'category!In the second place: (get 'name emp1) will ALWAYS return NIL, because the function call is incorrect.It should be: (get emp1 'name)In my examples this works ok:: (put emp1 'category 'engineer)-> engineer: (get emp1 'category)-> engineerAlso this works:: (with emp1     (prinl (: category)))engineer-> engineerBest,   Arie2018-06-10 16:14 GMT+02:00 Johann-Tobias Schäg <johtob...@gmail.com>: The first problem is that all your employees have no 'name property. ( get 'name emp1) -> NILBut emp1 -> "Abel"But there is something else rotten. I can not spot. But try to get (with 'emp1 (prinl (: name))) running firstRegarding your 'This question:  https://software-lab.de/doc/refT.html#ThisVon: xapw...@gmail.comGesendet: 10. Juni 2018 2:20 nachm.An: picolisp@software-lab.deAntworten: picolisp@software-lab.deBetreff: Stuck at PLEAC example  Hi Alex,I am now working on the "Arrays" section at "Find First Element that passes a Test".Your example:   (with      (find         '((This) (== 'engineer (: category)))         Employees )      (prinl "Highest paid engineer is: " (: name))  )This won't work of course, so I created a few things:   : (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5 "Zaphod")   -> "Zaphod"   : (put emp1 'category 'engineer)   -> engineer   : (put emp2 'category 'cook)   -> cook   : (put emp3 'category 'teacher)   -> teacher   : (put emp4 'category 'engineer)   -> engineer   : (put emp5 'category 'vicar)   -> vicar   : (setq Employees '(emp1 emp2 emp3 emp4 emp5))   -> (emp1 emp2 emp3 emp4 emp5)I guessed that this list Employees would be OK to feed 'find';however, from the ref docs of 'with' I do not grasp how I should get this to work.Also, the function used by 'find' has a formal parameter named This. Is this the PicoLisp special variable, or just a name for a formal parameter?Please give a complete example! What I experience now is exactly why I think that there should be more and better approachable docs.I think the reference should either be expanded by more comprehensive examples + explanations, or otherwise I'll try and do that later in the Wiki where I started the new section (with now only the 'de' example).I feel you, because it is all "in your head", but B2B a.k.a. brain-2-brain is not yet possible, regrettably :)Seeing all this stuf

Re: Stuck at PLEAC example

2018-06-10 Thread Johann-Tobias Schäg
  Also while pointer equality '== might be fine in this case '= makes more sense to me   Von: johtob...@gmail.comGesendet: 10. Juni 2018 5:31 nachm.An: picolisp@software-lab.deBetreff: Re: Stuck at PLEAC exampleYou are right. But that does not change the fact that your code will misbehave if you do not define a name.2. You did not mentioned mention how it does misbehavior so i assumed.   Von:  xapw...@gmail.comGesendet: 10. Juni 2018 5:25 nachm.An:  picolisp@software-lab.deAntworten:  picolisp@software-lab.deBetreff: Re: Stuck at PLEAC example  Hi Johann,I think that is not correct.In the first place I think I don't need a name property. Only the 'category!In the second place: (get 'name emp1) will ALWAYS return NIL, because the function call is incorrect.It should be: (get emp1 'name)In my examples this works ok:: (put emp1 'category 'engineer)-> engineer: (get emp1 'category)-> engineerAlso this works:: (with emp1     (prinl (: category)))engineer-> engineerBest,   Arie2018-06-10 16:14 GMT+02:00 Johann-Tobias Schäg <johtob...@gmail.com>: The first problem is that all your employees have no 'name property. ( get 'name emp1) -> NILBut emp1 -> "Abel"But there is something else rotten. I can not spot. But try to get (with 'emp1 (prinl (: name))) running firstRegarding your 'This question:  https://software-lab.de/doc/refT.html#ThisVon: xapw...@gmail.comGesendet: 10. Juni 2018 2:20 nachm.An: picolisp@software-lab.deAntworten: picolisp@software-lab.deBetreff: Stuck at PLEAC example  Hi Alex,I am now working on the "Arrays" section at "Find First Element that passes a Test".Your example:   (with      (find         '((This) (== 'engineer (: category)))         Employees )      (prinl "Highest paid engineer is: " (: name))  )This won't work of course, so I created a few things:   : (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5 "Zaphod")   -> "Zaphod"   : (put emp1 'category 'engineer)   -> engineer   : (put emp2 'category 'cook)   -> cook   : (put emp3 'category 'teacher)   -> teacher   : (put emp4 'category 'engineer)   -> engineer   : (put emp5 'category 'vicar)   -> vicar   : (setq Employees '(emp1 emp2 emp3 emp4 emp5))   -> (emp1 emp2 emp3 emp4 emp5)I guessed that this list Employees would be OK to feed 'find';however, from the ref docs of 'with' I do not grasp how I should get this to work.Also, the function used by 'find' has a formal parameter named This. Is this the PicoLisp special variable, or just a name for a formal parameter?Please give a complete example! What I experience now is exactly why I think that there should be more and better approachable docs.I think the reference should either be expanded by more comprehensive examples + explanations, or otherwise I'll try and do that later in the Wiki where I started the new section (with now only the 'de' example).I feel you, because it is all "in your head", but B2B a.k.a. brain-2-brain is not yet possible, regrettably :)Seeing all this stuff i am convinced that PicoLisp also could have been named YottaLisp, because of the sheer amount of possibilities hidden below the surface :)Best,   Arie



Re: Stuck at PLEAC example

2018-06-10 Thread Johann-Tobias Schäg
  You are right. But that does not change the fact that your code will misbehave if you do not define a name.2. You did not mentioned mention how it does misbehavior so i assumed.   Von: xapw...@gmail.comGesendet: 10. Juni 2018 5:25 nachm.An: picolisp@software-lab.deAntworten: picolisp@software-lab.deBetreff: Re: Stuck at PLEAC example  Hi Johann,I think that is not correct.In the first place I think I don't need a name property. Only the 'category!In the second place: (get 'name emp1) will ALWAYS return NIL, because the function call is incorrect.It should be: (get emp1 'name)In my examples this works ok:: (put emp1 'category 'engineer)-> engineer: (get emp1 'category)-> engineerAlso this works:: (with emp1     (prinl (: category)))engineer-> engineerBest,   Arie2018-06-10 16:14 GMT+02:00 Johann-Tobias Schäg <johtob...@gmail.com>: The first problem is that all your employees have no 'name property. ( get 'name emp1) -> NILBut emp1 -> "Abel"But there is something else rotten. I can not spot. But try to get (with 'emp1 (prinl (: name))) running firstRegarding your 'This question:  https://software-lab.de/doc/refT.html#ThisVon: xapw...@gmail.comGesendet: 10. Juni 2018 2:20 nachm.An: picolisp@software-lab.deAntworten: picolisp@software-lab.deBetreff: Stuck at PLEAC example  Hi Alex,I am now working on the "Arrays" section at "Find First Element that passes a Test".Your example:   (with      (find         '((This) (== 'engineer (: category)))         Employees )      (prinl "Highest paid engineer is: " (: name))  )This won't work of course, so I created a few things:   : (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5 "Zaphod")   -> "Zaphod"   : (put emp1 'category 'engineer)   -> engineer   : (put emp2 'category 'cook)   -> cook   : (put emp3 'category 'teacher)   -> teacher   : (put emp4 'category 'engineer)   -> engineer   : (put emp5 'category 'vicar)   -> vicar   : (setq Employees '(emp1 emp2 emp3 emp4 emp5))   -> (emp1 emp2 emp3 emp4 emp5)I guessed that this list Employees would be OK to feed 'find';however, from the ref docs of 'with' I do not grasp how I should get this to work.Also, the function used by 'find' has a formal parameter named This. Is this the PicoLisp special variable, or just a name for a formal parameter?Please give a complete example! What I experience now is exactly why I think that there should be more and better approachable docs.I think the reference should either be expanded by more comprehensive examples + explanations, or otherwise I'll try and do that later in the Wiki where I started the new section (with now only the 'de' example).I feel you, because it is all "in your head", but B2B a.k.a. brain-2-brain is not yet possible, regrettably :)Seeing all this stuff i am convinced that PicoLisp also could have been named YottaLisp, because of the sheer amount of possibilities hidden below the surface :)Best,   Arie



Re: Stuck at PLEAC example

2018-06-10 Thread Arie van Wingerden
Hi Johann,

I think that is not correct.

In the first place I think I don't need a name property. Only the 'category!

In the second place: (get 'name emp1) will ALWAYS return NIL, because the
function call is incorrect.
It should be: (get emp1 'name)

In my examples this works ok:
: (put emp1 'category 'engineer)
-> engineer
: (get emp1 'category)
-> engineer

Also this works:
: (with emp1
 (prinl (: category)))
engineer
-> engineer

Best,
   Arie

2018-06-10 16:14 GMT+02:00 Johann-Tobias Schäg :

>
>
> The first problem is that all your employees have no 'name property. ( get
> 'name emp1) -> NIL
> But emp1 -> "Abel"
>
> But there is something else rotten. I can not spot. But try to get (with
> 'emp1 (prinl (: name))) running first
>
> Regarding your 'This question:
>  https://software-lab.de/doc/refT.html#This
>
>
> *Von:* xapw...@gmail.com
> *Gesendet:* 10. Juni 2018 2:20 nachm.
> *An:* picolisp@software-lab.de
> *Antworten:* picolisp@software-lab.de
> *Betreff:* Stuck at PLEAC example
>
> Hi Alex,
>
> I am now working on the "Arrays" section at "Find First Element that
> passes a Test".
>
> Your example:
>(with
>   (find
>  '((This) (== 'engineer (: category)))
>  Employees )
>   (prinl "Highest paid engineer is: " (: name))  )
>
> This won't work of course, so I created a few things:
>: (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5
> "Zaphod")
>-> "Zaphod"
>
>: (put emp1 'category 'engineer)
>-> engineer
>
>: (put emp2 'category 'cook)
>-> cook
>
>: (put emp3 'category 'teacher)
>-> teacher
>
>: (put emp4 'category 'engineer)
>-> engineer
>
>: (put emp5 'category 'vicar)
>-> vicar
>
>: (setq Employees '(emp1 emp2 emp3 emp4 emp5))
>-> (emp1 emp2 emp3 emp4 emp5)
>
> I guessed that this list Employees would be OK to feed 'find';
> however, from the ref docs of 'with' I do not grasp how I should get this
> to work.
>
> Also, the function used by 'find' has a formal parameter named This. Is
> this the PicoLisp special variable, or just a name for a formal parameter?
>
> Please give a complete example!
>
> What I experience now is exactly why I think that there should be more and
> better approachable docs.
>
> I think the reference should either be expanded by more comprehensive
> examples + explanations, or otherwise I'll try and do that later in the
> Wiki where I started the new section (with now only the 'de' example).
>
> I feel you, because it is all "in your head", but B2B a.k.a. brain-2-brain
> is not yet possible, regrettably :)
>
> Seeing all this stuff i am convinced that PicoLisp also could have been
> named YottaLisp, because of the sheer amount of possibilities hidden below
> the surface :)
>
> Best,
>Arie
>


Re: Stuck at PLEAC example

2018-06-10 Thread Alexander Burger
On Sun, Jun 10, 2018 at 02:13:10PM +0200, Arie van Wingerden wrote:
> Please give a complete example!

I would do it this way:

   (setq Employees '(emp1 emp2 emp3 emp4 emp5))

   (mapc put
  Employees
  '(name .)
  '("Abel" "Jones" "Millner" "Noles" "Zaphod") )

   (mapc put
  Employees
  '(category .)
  '(engineer cook teacher engineer vicar) )

   (mapc show Employees)
   
   (with
  (find
 '((This) (== 'engineer (: category)))
 Employees )
  (prinl "Highest paid engineer is: " (: name))  )


Output:
   emp1 NIL
  category engineer
  name "Abel"
   emp2 NIL
  category cook
  name "Jones"
   emp3 NIL
  category teacher
  name "Millner"
   emp4 NIL
  category engineer
  name "Noles"
   emp5 NIL
  category vicar
  name "Zaphod"
   Highest paid engineer is: Abel

♪♫ Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Stuck at PLEAC example

2018-06-10 Thread Johann-Tobias Schäg
 The first problem is that all your employees have no 'name property. ( get 'name emp1) -> NILBut emp1 -> "Abel"But there is something else rotten. I can not spot. But try to get (with 'emp1 (prinl (: name))) running firstRegarding your 'This question:  https://software-lab.de/doc/refT.html#ThisVon: xapw...@gmail.comGesendet: 10. Juni 2018 2:20 nachm.An: picolisp@software-lab.deAntworten: picolisp@software-lab.deBetreff: Stuck at PLEAC example  Hi Alex,I am now working on the "Arrays" section at "Find First Element that passes a Test".Your example:   (with      (find         '((This) (== 'engineer (: category)))         Employees )      (prinl "Highest paid engineer is: " (: name))  )This won't work of course, so I created a few things:   : (setq emp1 "Abel" emp2 "Jones" emp3 "Millner" emp4 "Noles" emp5 "Zaphod")   -> "Zaphod"   : (put emp1 'category 'engineer)   -> engineer   : (put emp2 'category 'cook)   -> cook   : (put emp3 'category 'teacher)   -> teacher   : (put emp4 'category 'engineer)   -> engineer   : (put emp5 'category 'vicar)   -> vicar   : (setq Employees '(emp1 emp2 emp3 emp4 emp5))   -> (emp1 emp2 emp3 emp4 emp5)I guessed that this list Employees would be OK to feed 'find';however, from the ref docs of 'with' I do not grasp how I should get this to work.Also, the function used by 'find' has a formal parameter named This. Is this the PicoLisp special variable, or just a name for a formal parameter?Please give a complete example! What I experience now is exactly why I think that there should be more and better approachable docs.I think the reference should either be expanded by more comprehensive examples + explanations, or otherwise I'll try and do that later in the Wiki where I started the new section (with now only the 'de' example).I feel you, because it is all "in your head", but B2B a.k.a. brain-2-brain is not yet possible, regrettably :)Seeing all this stuff i am convinced that PicoLisp also could have been named YottaLisp, because of the sheer amount of possibilities hidden below the surface :)Best,   Arie