Re: +QueryChart without pilog

2019-11-27 Thread C K Kashyap
Hurray!!!
Thank you so much Alex,
Just to confirm if I've understood correctly - this solution is similar
to (nm +CuSu @Sup (sup +Item) (itm +Pos) ord) from the sample app correct?
Instead of (nm +CuSu @Sup) we have (nm +TagVal @Col1  nm +TagVal) - right?

I need one more help - writing a function that take a list of strings
(Tags) and executes the pilog query with all the strings "anded" for
example, if I call (MakeQ "RED" BLUE" ) should return all items that have
three TAGs. Here's my attempt. It works...but I have a strong feeling that
there must be a better way to do it :)

(de MakeQ Tags
(let (
Col '( (N) (intern (pack '@Col N)))
L1 (let C 1 (make (for T Tags (link (Col C)) (link T) (setq C (inc
C)
L2 (let C 1 (make (for T Tags (link 'nm) (link '+TagVal) (link (Col
C)) (setq C (inc C)
L3 (let C 1 (make (for T Tags (link (list 'same (Col C) '@Item 'tgs
'v 'nm))  (setq C (inc C)

Code (list (list 'pilog
   (cons 'quote
(append L1
(list
  (append (list 'select (list '@Item) (list
(list L2 (list 'v '+Tag) 'itm)) ) L3   ) ) ))
(list 'print-item '@Item) ))

)
 (run Code)
)
)


Regards,
Kashyap

On Tue, Nov 26, 2019 at 11:01 PM Alexander Burger 
wrote:

> On Tue, Nov 26, 2019 at 02:06:25PM -0800, C K Kashyap wrote:
> > It seems to work as expected using collects :) Here's the complete
> program
> > - it prints out ITEM1 and ITEM6 as expected.
>
> Ah, right, you select items, not tags, and items have a *list* of tags.
>
> OK. Then to get AND, you can instead of an explicit OR clause
>
>...
>(or ((same @Col1 @Tag v nm)) ((same @Col2 @Tag v nm)))
>...
>
> simply employ the inherent AND mechanism of Pilog/Prolog
>
>...
>(same @Col1 @Item tgs v nm)
>(same @Col2 @Item tgs v nm)
>...
>
>
> With your example, this works:
>
>(pilog
>   (quote
>  @Col1 "RED"
>  @Col2 "BLUE"
>  (select (@Item)
> (((nm +TagVal @Col1  nm +TagVal @Col2) (v +Tag) itm))
> (same @Col1 @Item tgs v nm)
> (same @Col2 @Item tgs v nm) ) )
>   (print-item @Item) )
>
>
> BTW, as the names of +TagVal seem unique, and substrings are not searched,
> it is
> better to use +Key instead of +IdxFold:
>
>(class +TagVal +Entity)
>(rel nm (+Key +String))
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Unsubscribe

2019-11-27 Thread Derenik Mikaelyan
Thanks,

Derenik