No problem Alex,
 (collect 'tgs '+Item (db 'nm '+Tag "BLUE")) does not seem to work for me -
returns NIL. For that matter, even (collect 'tgs '+Item) returns NIL. I
wonder if its because 'tgs does not have +Idx in the relation

(class +Item +Entity)

(rel ttl (+IdxFold +String))

(rel tgs (+List +Joint) itm (+Tag))

(rel sts (+IdxFold +String))


Also,  (mapcar '((This) (: itm)) (collect 'nm '+Tag "BLUE")) worked fine -
now I see the beauty of "This" better. Btw, I had to get rid of "T" in (collect
'nm '+Tag "BLUE" NIL T 'itm) to get it to work.


Regards,

Kashyap






On Thu, Nov 21, 2019 at 11:11 PM Alexander Burger <a...@software-lab.de>
wrote:

> Hi Kashyap,
>
> sorry, I was busy! I did not find the time to install and deeply check all
> your
> code.
>
>
> > 1. Query all open items that have the given tag
>
> >> I think I have a workaround for my question 1 :) - if I use the status
> as
> >> an inline relation instead of a link that is.
>
> I think it makes no difference. It is OK if the status is an object.
>
>    (collect 'tgs '+Item (db 'nm '+Tag "foo"))
>
> or
>
>    (mapcan
>       '((Tag)
>          (collect 'tgs '+Item Tag) )
>       (collect 'nm '+Tag "foo") )
>
>
>
> > 2. Query all items that have "ALL" the given tags - for example all
> > items tagged with RED and GREEN -> this should only generate ITEM3
>
> Doesn't the above 'mapcan' do that?
>
>
> > Okay - I've got the answer to the second question as well. I am not sure
> of
> > the efficiency though - I essentially collect all items that have the tag
> > RED and then collect all the items that have the BLUE and then do "sect"
> on
> > the output lists. Is this reasonable?
> >
> >
> > (setq L1 (mapcar '( (I) (get I 'itm)) (collect 'nm '+Tag "BLUE")))
> >
> > (setq L2 (mapcar '( (I) (get I 'itm)) (collect 'nm '+Tag "RED")))
>
>
> Yes, I would just write
>
>    (mapcar '((This) (: itm)) (collect 'nm '+Tag "BLUE"))
>
>
> but using the advantage of 'collect', the following should give the same
> result:
>
>    (collect 'nm '+Tag "BLUE" NIL T 'itm)
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to