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?


Gesendet: 10. Juni 2018 5:43 nachm.
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.
Gesendet: 10. Juni 2018 5:33 nachm.
Betreff: Re: Stuck at PLEAC example

Also while pointer equality '== might be fine in this case '= makes more sense to me

Gesendet: 10. Juni 2018 5:31 nachm.
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.

Gesendet: 10. Juni 2018 5:25 nachm.
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 <[email protected]>:


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: 


Gesendet: 10. Juni 2018 2:20 nachm.
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

Reply via email to