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? : (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. Also while pointer equality '== might be fine in this case '= makes more sense to me 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.
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]>:
| ||||||||||
- Stuck at PLEAC example Arie van Wingerden
- Re: Stuck at PLEAC example Johann-Tobias Schäg
- Re: Stuck at PLEAC example Arie van Wingerden
- Re: Stuck at PLEAC example Johann-Tobias Schäg
- Re: Stuck at PLEAC example Johann-Tobias Schäg
- Re: Stuck at PLEAC example Johann-Tobias Schäg
- Re: Stuck at PLEAC example Johann-Tobias Schäg
- Re: Stuck at PLEAC exam... Arie van Wingerden
- Re: Stuck at PLEAC example Arie van Wingerden
- Re: Stuck at PLEAC example Arie van Wingerden
- Re: Stuck at PLEAC example Arie van Wingerden
- Re: Stuck at PLEAC example Alexander Burger
- Re: Stuck at PLEAC example Arie van Wingerden
- Re: Stuck at PLEAC example Arie van Wingerden
