Hi Grant,

welcome here :)

> My name is Grant and I'm just getting started with picolisp. I'm trying an
> exercise to model user-groups and memberships with the Entity/Relation 
> database.
> I must be misunderstanding something, or doing something strange because I
> can't seem to create/retrieve items the way I expect to. For example:

I think you did everything perfectly right.

But 'iter' is a rather low-level function. If you call it as

> (iter (tree 'name '+User) '((This) (println (: name))))

it prints *all* entries in the b-tree. As your 'name' relation is an '+Idx', it
creates several entries per value.

If you want to iterate only the primary entries, you can pass a boolean 5th
argument to 'iter':

   (iter (tree 'name '+User)
      '((This) (println (: name)))
      NIL
      T
      T )

Or use one of the higher-level functions which know about the relations and
handle them properly

   (collect 'name '+User)
   (collect 'name '+User NIL T 'name)

In interactive mode you can also just

   (select +User)
   (select +User name "Grant")
   (select nr name memberships +User name "Grant")

☺/ A!ex

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

Reply via email to