Re: +QueryChart without pilog

2019-12-06 Thread C K Kashyap
Awesome ... the +Val also has the good sideeffect that the UI is
updated to upper case :)

It's wonderful to gather these PicoLisp nuggets of wisdom!!! Thanks Alex.

Regards,
Kashyap

On Fri, Dec 6, 2019 at 6:41 AM Alexander Burger  wrote:

> On Fri, Dec 06, 2019 at 03:24:25PM +0100, Alexander Burger wrote:
> >(gui 'tags '(+Var +Val +ListTextField)
> >   '*Tags
> >   '((L) (extract '((X) (uppc (pack X))) L))
> >   '("," " ")
> >   20 )
>
> Ah, and of course +ListTextField already returns a list of strings, so the
> 'pack' should not be necessary.
>
> Just
>
>'((L) (extract uppc L))
>
> should be enough (not tested).
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-12-06 Thread Alexander Burger
On Fri, Dec 06, 2019 at 03:24:25PM +0100, Alexander Burger wrote:
>(gui 'tags '(+Var +Val +ListTextField)
>   '*Tags
>   '((L) (extract '((X) (uppc (pack X))) L))
>   '("," " ")
>   20 )

Ah, and of course +ListTextField already returns a list of strings, so the
'pack' should not be necessary.

Just

   '((L) (extract uppc L))

should be enough (not tested).

☺/ A!ex

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


Re: +QueryChart without pilog

2019-12-06 Thread Alexander Burger
On Thu, Dec 05, 2019 at 07:11:43PM -0800, C K Kashyap wrote:
> Okay, my choTask looks like this now - as you can see, I assigned a list
> to @Names and then assigned the 'car' of the list to @Key. The way I
> avoided repetition was by assigning to a global symbol '*Names' - is that
> reasonable?
> 
>  
>  "Tags" (gui 'tags '(+Var +ListTextField) '*Tags '("," " ") 20 )
>  (searchButton '(init> (: home query))) )
>   (gui 'query '(+QueryChart) *ROWS
>  '(goal
> '(@Names (setq *Names (filter prog (mapcar '((X) (uppc (pack X))) 
> *Tags)) )
>@Key (car *Names)

Yes, this works, but I agree that using a global does not feel right.

I would suggest to handle it directly in the GUI

   ...
   "Tags"
   (gui 'tags '(+Var +Val +ListTextField)
  '*Tags
  '((L) (filter prog (mapcar '((X) (uppc (pack X))) L)))
  '("," " ")
  20 )
   ...

so that '*Tags' immediately has the filtered uppercase values.

Also, we can avoid mapping the list twice (mapcar and then filter). 'extract' is
intended for such cases:

   (gui 'tags '(+Var +Val +ListTextField)
  '*Tags
  '((L) (extract '((X) (uppc (pack X))) L))
  '("," " ")
  20 )

☺/ A!ex

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


Re: +QueryChart without pilog

2019-12-05 Thread C K Kashyap
Okay, my choTask looks like this now - as you can see, I assigned a list
to @Names and then assigned the 'car' of the list to @Key. The way I
avoided repetition was by assigning to a global symbol '*Names' - is that
reasonable?

 
 "Tags" (gui 'tags '(+Var +ListTextField) '*Tags '("," " ") 20 )
 (searchButton '(init> (: home query))) )
  (gui 'query '(+QueryChart) *ROWS
 '(goal
'( @Names (setq *Names (filter prog (mapcar '((X) (uppc (pack
X))) *Tags) ) )
   @Key (car *Names)
   (select (@@)
  ((nm +TagNm @Key (nm +Tag) tsk))
  (^ @
 (fully '((Nm)
   (find
  '((This) (member Nm (: nm nm)))
  (; (-> @@) tgs) ) )
(-> @Names) ) ) ) ) )
 1
 '((This) (list This)) )
  ( ...

Regards,
Kashyap

On Thu, Dec 5, 2019 at 10:36 AM C K Kashyap  wrote:

> Super! .. thanks Alex,
> Regards,
> Kashyap
>
> On Thu, Dec 5, 2019 at 9:23 AM Alexander Burger 
> wrote:
>
>> On Thu, Dec 05, 2019 at 08:34:34AM -0800, C K Kashyap wrote:
>> > About the "filtering with a no-op" - that was my way of getting rid of
>> > NIL's in the list - what's the right way :) ?
>>
>> Ah, yes, sure! A valid solution!
>>
>> I just did not trigger on that pattern, because I use (filter prog Lst),
>> or
>> sometimes (filter bool Lst) for that without further thinking.
>>
>> ((X) X) has a high overhead due to the EXPR function call. It binds and
>> unbinds
>> the X parameter, and runs the (almost empty) body between that.
>>
>> 'prog' is the ideal no-op function, as it evaluates all arguments, does
>> nothing else, and is a built-in and fast as such.
>>
>> ☺/ A!ex
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>


Re: +QueryChart without pilog

2019-12-05 Thread C K Kashyap
Super! .. thanks Alex,
Regards,
Kashyap

On Thu, Dec 5, 2019 at 9:23 AM Alexander Burger  wrote:

> On Thu, Dec 05, 2019 at 08:34:34AM -0800, C K Kashyap wrote:
> > About the "filtering with a no-op" - that was my way of getting rid of
> > NIL's in the list - what's the right way :) ?
>
> Ah, yes, sure! A valid solution!
>
> I just did not trigger on that pattern, because I use (filter prog Lst), or
> sometimes (filter bool Lst) for that without further thinking.
>
> ((X) X) has a high overhead due to the EXPR function call. It binds and
> unbinds
> the X parameter, and runs the (almost empty) body between that.
>
> 'prog' is the ideal no-op function, as it evaluates all arguments, does
> nothing else, and is a built-in and fast as such.
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-12-05 Thread Alexander Burger
On Thu, Dec 05, 2019 at 08:34:34AM -0800, C K Kashyap wrote:
> About the "filtering with a no-op" - that was my way of getting rid of
> NIL's in the list - what's the right way :) ?

Ah, yes, sure! A valid solution!

I just did not trigger on that pattern, because I use (filter prog Lst), or
sometimes (filter bool Lst) for that without further thinking.

((X) X) has a high overhead due to the EXPR function call. It binds and unbinds
the X parameter, and runs the (almost empty) body between that.

'prog' is the ideal no-op function, as it evaluates all arguments, does
nothing else, and is a built-in and fast as such.

☺/ A!ex

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


Re: +QueryChart without pilog

2019-12-05 Thread C K Kashyap
Thanks Alex,

About the "filtering with a no-op" - that was my way of getting rid of
NIL's in the list - what's the right way :) ?

Regards,
Kashyap

On Thu, Dec 5, 2019 at 7:50 AM Alexander Burger  wrote:

> Hi Kashyap,
>
> > The question I have now is about cases where we may need a couple of
> pilog
> > variables of the form -
> >  @Names XXX
> >  @Gen (mapcan '((Nm) (list 'nm '+TagNm Nm)) 'XXX)
> >
> > where XXX needs to be substituted with an expression - (filter '((X) X)
> > (mapcar '((X) (uppc (pack X)))  *Tags))) in this case. As I was
> > experimenting for writing this email, using function calls to do the
> > "substitution" seems to work. For some reason, it was not working for me
> > when I tried yesterday.
>
> Yeah, this should be no general problem. In all those patterns
>
>@Var (expression)
>
> (expression) is an arbitrary Lisp expression, so you are completely free
> to call
> other functions etc.
>
>
> > This seems to work too -
> > '(
> >@Names (YY)
> >@Gen (mapcan '((Nm) (list 'nm '+TagNm Nm)) '(YY T))
> >(select (@@)
> > ((@Gen (nm +Tag) tsk))
> > (^ @
> >  (fully
> >   '((Nm)
> >   (find
> >'((This) (member Nm (: nm nm)))
> >(; (-> @@) tgs) ) )
> >   (-> @Names) ) )
> >)
> > )
> >
> > where YY is defined as -
>
> Well, in the above @Gen expression, 'YY' is used as a *name* in the quoted
> list,
> so it does not matter if and how it is defined.
>
> Or is the quote wrong?
>
>
> > (de YY (QT)
> > (filter '((X) X) (mapcar '((X) (uppc (pack X)))  *Tags)))
> > One thing odd I find is that the code "does not work" when I call YY with
> > NIL or without an argument in the second case (@Gen)
>
> The 'QT' parameter is ignored anyway.
>
> Side note: Why do you filter with a no-op function? Or is this just a
> placeholder for testing?
>
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-12-05 Thread Alexander Burger
Hi Kashyap,

> The question I have now is about cases where we may need a couple of pilog
> variables of the form -
>  @Names XXX
>  @Gen (mapcan '((Nm) (list 'nm '+TagNm Nm)) 'XXX)
> 
> where XXX needs to be substituted with an expression - (filter '((X) X)
> (mapcar '((X) (uppc (pack X)))  *Tags))) in this case. As I was
> experimenting for writing this email, using function calls to do the
> "substitution" seems to work. For some reason, it was not working for me
> when I tried yesterday.

Yeah, this should be no general problem. In all those patterns

   @Var (expression)

(expression) is an arbitrary Lisp expression, so you are completely free to call
other functions etc.


> This seems to work too -
> '(
>@Names (YY)
>@Gen (mapcan '((Nm) (list 'nm '+TagNm Nm)) '(YY T))
>(select (@@)
> ((@Gen (nm +Tag) tsk))
> (^ @
>  (fully
>   '((Nm)
>   (find
>'((This) (member Nm (: nm nm)))
>(; (-> @@) tgs) ) )
>   (-> @Names) ) )
>)
> )
> 
> where YY is defined as -

Well, in the above @Gen expression, 'YY' is used as a *name* in the quoted list,
so it does not matter if and how it is defined.

Or is the quote wrong?


> (de YY (QT)
> (filter '((X) X) (mapcar '((X) (uppc (pack X)))  *Tags)))
> One thing odd I find is that the code "does not work" when I call YY with
> NIL or without an argument in the second case (@Gen)

The 'QT' parameter is ignored anyway.

Side note: Why do you filter with a no-op function? Or is this just a
placeholder for testing?


☺/ A!ex

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


Re: +QueryChart without pilog

2019-12-05 Thread C K Kashyap
Oh! ... now I see the spacing problem .. sorry about that, I think it must
be the result of copying from the terminal and pasting.

The last proposal was perfect - indeed it works just fine for tags (I've
tried different pasting this time).

(de choTask (Dst)
   (diaform '(Dst)
( "--"
 "Name" (gui 'ttl '(+DbHint +Var +TextField) '(ttl
+Task) '*Name 20)
 "Tags" (gui 'tags '(+Var +ListTextField) '*Tags
'(","," ") 20)
 (searchButton '(init> (: home query)))
 )
(gui 'query '(+QueryChart) *ROWS
   '(goal
 '(
 @Names (filter '((X) X) (mapcar '((X) (uppc (pack
X)))  *Tags))
 @Key (car (filter '((X) X) (mapcar '((X) (uppc
(pack X))) *Tags)))
 (select (@@)
  ((nm +TagNm @Key (nm +Tag) tsk))
  (^ @
   (fully
'((Nm)
(find
 '((This) (member Nm (: nm nm)))
 (; (-> @@) tgs) ) )
(-> @Names) ) )


The question I have now is about cases where we may need a couple of pilog
variables of the form -
 @Names XXX
 @Gen (mapcan '((Nm) (list 'nm '+TagNm Nm)) 'XXX)

where XXX needs to be substituted with an expression - (filter '((X) X)
(mapcar '((X) (uppc (pack X)))  *Tags))) in this case. As I was
experimenting for writing this email, using function calls to do the
"substitution" seems to work. For some reason, it was not working for me
when I tried yesterday.

This seems to work too -
'(
   @Names (YY)
   @Gen (mapcan '((Nm) (list 'nm '+TagNm Nm)) '(YY T))
   (select (@@)
((@Gen (nm +Tag) tsk))
(^ @
 (fully
  '((Nm)
  (find
   '((This) (member Nm (: nm nm)))
   (; (-> @@) tgs) ) )
  (-> @Names) ) )
   )
)

where YY is defined as -
(de YY (QT)
(filter '((X) X) (mapcar '((X) (uppc (pack X)))  *Tags)))

One thing odd I find is that the code "does not work" when I call YY with
NIL or without an argument in the second case (@Gen)

I think I'll have to do some more experiments to come up with precise
questions. In the meantime, the tags logic works for me :)


Regards,
Kashyap



On Wed, Dec 4, 2019 at 10:53 PM Alexander Burger 
wrote:

> On Wed, Dec 04, 2019 at 02:32:57PM -0800, C K Kashyap wrote:
> > (patch choTask 'XXX '(filter '((X) X) (mapcar '((X) (uppc (pack X)))
> > *Tags)))
> > ...
>
> I do not understand your intention. I thougt you wanted an AND of all
> tags, so
> the @Gen generator was obsolete.
>
> My last proposal was:
>
> (de f (Names)
>(pilog
>   (quote
>  @Names Names
>  @Key (car Names)
>  (select (@Item)
> ((nm +TagVal @Key (v +Tag) itm))
> (^ @
>(fully
>   '((Nm)
>  (find
> '((This) (member Nm (: v nm)))
> (; (-> @Item) tgs) ) )
>   (-> @Names) ) ) ) )
>   (print-item @Item) ) )
>
>(f '("RED" "BLUE"))
>
> What was wrong with it?
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-12-04 Thread Alexander Burger
On Wed, Dec 04, 2019 at 02:32:57PM -0800, C K Kashyap wrote:
> (patch choTask 'XXX '(filter '((X) X) (mapcar '((X) (uppc (pack X)))
> *Tags)))
> ...

I do not understand your intention. I thougt you wanted an AND of all tags, so
the @Gen generator was obsolete.

My last proposal was:

(de f (Names)
   (pilog
  (quote
 @Names Names
 @Key (car Names)
 (select (@Item)
((nm +TagVal @Key (v +Tag) itm))
(^ @
   (fully
  '((Nm)
 (find
'((This) (member Nm (: v nm)))
(; (-> @Item) tgs) ) )
  (-> @Names) ) ) ) )
  (print-item @Item) ) )

   (f '("RED" "BLUE"))

What was wrong with it?

☺/ A!ex

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


Re: +QueryChart without pilog

2019-12-04 Thread Alexander Burger
Hi Kashyap,

> (de choTask (Dst)
> 
>(diaform
> 
>   '(Dst)
> 
>   (
> 
>  "--"
> 
>  "Name"
> 
>  (gui
> 
> 'ttl
> 
> '(+DbHint +Var +TextField)
> 
> '(ttl +Task)

Hmm, OK, perhaps not to *that* extreme. 'pretty' was not a good advice in this
case (I meant more the line spacing, indentation and parentheses). A better
guide are simply the existing examples.

But why are all lines spread out so much? Is it your mail client? To see what I
see, you could check

   https://www.mail-archive.com/picolisp@software-lab.de/msg09262.html

It is unreadable imho.

☺/ A!ex

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


Re: +QueryChart without pilog

2019-12-04 Thread C K Kashyap
Okay, I have a working version but I think I should be able to do it more
elegantly. I have the complete choTask function below (pretty printed
ofcourse :) ) I have the repeating pattern as XXX which I replace using
patch -

(patch choTask 'XXX '(filter '((X) X) (mapcar '((X) (uppc (pack X)))
*Tags)))
Which works but seems to me like I am not using "macros" correctly.


(de choTask (Dst)

   (diaform

  '(Dst)

  (

 "--"

 "Name"

 (gui

'ttl

'(+DbHint +Var +TextField)

'(ttl +Task)

'*Name

20 )

 "Tags"

 (gui

'tags

'(+Var +ListTextField)

'*Tags

'("," " ")

20 )

 (searchButton '(init> (: home query))) )

  (gui

 'query

 '(+QueryChart)

 *ROWS

 '(goal

'(@Names

   XXX

   @Gen

   (mapcan

  '((Nm) (list 'nm '+TagNm Nm))

  'XXX )

   (select

  (@@)

  ((@Gen (nm +Tag) tsk))

  (^

 @

 (fully

'((Nm)

   (find

  '((This) (member Nm (: nm nm)))

  (; (-> @@) tgs) ) )

(-> @Names) ) ) ) ) )

 1

 '((This) (list This)) )

  (

 NIL

 (choTtl "Entries" '+Task)

 '(("em20 align" "Name"))

 (do *ROWS

(

   NIL

   (gui 1 '(+ObjView +TextField) '(: ttl)) ) ) )

  ( (scroll *ROWS) (newButton T Dst '(+Task))) ) )


On Wed, Dec 4, 2019 at 5:43 AM C K Kashyap  wrote:

> Thanks Alex,
> Sure, I'll do a pp in future - also start following that conventions.
>
> About @Gen using @Names - the second argument of mapcan in the definition
> of @Gen is essentially @Names. I am looking for a way to avoid having to
> repeat the expression (filter ...
>
>
> (gui
>
>   'query
>
>   '(+QueryChart)
>
>   *ROWS
>
>   '(goal
>
>  '(@Names
>
> (filter
>
>'((X) X)
>
>(mapcar
>
>   '((X) (uppc (pack X)))
>
>   (split (chop *Tags) " ") ) )
>
> @Gen
>
> (mapcan
>
>'((Nm) (list 'nm '+TagNm Nm))
>
>'(filter
>
>   '((X) X)
>
>   (mapcar
>
>  '((X) (uppc (pack X)))
>
>  (split (chop *Tags) " ") ) ) )
>
> (select
>
>(@@)
>
>((@Gen (nm +Tag) tsk))
>
>(^
>
>   @
>
>   (fully
>
>  '((Nm)
>
> (find
>
>'((This) (member Nm (: nm nm)))
>
>(; (-> @@) tgs) ) )
>
>  (-> @Names) ) ) ) ) )
>
>   1
>
>   '((This) (list This)) )
>
>
>
>
> Regards,
> Kashyap
>
> On Wed, Dec 4, 2019 at 3:07 AM Alexander Burger 
> wrote:
>
>> Hi Kashyap,
>>
>> On Tue, Dec 03, 2019 at 07:48:58PM -0800, C K Kashyap wrote:
>> > I'll need a little bit more help with Pilog in QueryChart - In the code
>> > below,
>>
>> Could you in the future provide code which is formatted in a more
>> readable way?
>> It is very hard to decipher. Better no spaces between lines, and
>> indentations
>> and parentheses more to the standard (see the output of 'pretty' and
>> 'pp').
>>
>> If I try to fix it manually, I get (hope I did not destroy anything):
>>
>>(diaform '(Dst)
>>   ( "--"
>>  "Name" (gui 'ttl '(+DbHint +Var +TextField) '(ttl > Task) '*Name
>> 20)
>>  "Tags" (gui 'tags '(+Var +TextField) '*Tags 20)
>>  (searchButton '(init> (: home query))) )
>>   (gui 'query '(+QueryChart) *ROWS
>>  '(goal
>> (quote
>>@Names
>>(filter
>>   '((X) X)
>>  (mapcar
>> '((X) (uppc (pack X)) )
>> (split (chop *Tags) " ") ) )
>>@Gen
>>(mapcan
>>   '((Nm) (list 'nm '+TagNm Nm))
>>   '(filter  # Commented?
>>  '((X) X)  #??
>>  (mapcar
>> '((X) (uppc (pack X)))
>> (split (chop *Tags) " ") ) ) )
>>(select (@@)
>>   ((@Gen (nm +Tag) tsk))
>>   (^ @
>>  (fully
>> '((Nm)
>>(find
>>   '((This) (or T (member Nm (: nm nm  # T?
>>   (; (-> @@) tgs) ) )
>> (-> @Names) ) ) ) ) )
>>  1
>>  '((This) (list This)) )
>>
>> (I assume the 

Re: +QueryChart without pilog

2019-12-04 Thread C K Kashyap
Thanks Alex,
Sure, I'll do a pp in future - also start following that conventions.

About @Gen using @Names - the second argument of mapcan in the definition
of @Gen is essentially @Names. I am looking for a way to avoid having to
repeat the expression (filter ...


(gui

  'query

  '(+QueryChart)

  *ROWS

  '(goal

 '(@Names

(filter

   '((X) X)

   (mapcar

  '((X) (uppc (pack X)))

  (split (chop *Tags) " ") ) )

@Gen

(mapcan

   '((Nm) (list 'nm '+TagNm Nm))

   '(filter

  '((X) X)

  (mapcar

 '((X) (uppc (pack X)))

 (split (chop *Tags) " ") ) ) )

(select

   (@@)

   ((@Gen (nm +Tag) tsk))

   (^

  @

  (fully

 '((Nm)

(find

   '((This) (member Nm (: nm nm)))

   (; (-> @@) tgs) ) )

 (-> @Names) ) ) ) ) )

  1

  '((This) (list This)) )




Regards,
Kashyap

On Wed, Dec 4, 2019 at 3:07 AM Alexander Burger  wrote:

> Hi Kashyap,
>
> On Tue, Dec 03, 2019 at 07:48:58PM -0800, C K Kashyap wrote:
> > I'll need a little bit more help with Pilog in QueryChart - In the code
> > below,
>
> Could you in the future provide code which is formatted in a more readable
> way?
> It is very hard to decipher. Better no spaces between lines, and
> indentations
> and parentheses more to the standard (see the output of 'pretty' and 'pp').
>
> If I try to fix it manually, I get (hope I did not destroy anything):
>
>(diaform '(Dst)
>   ( "--"
>  "Name" (gui 'ttl '(+DbHint +Var +TextField) '(ttl > Task) '*Name
> 20)
>  "Tags" (gui 'tags '(+Var +TextField) '*Tags 20)
>  (searchButton '(init> (: home query))) )
>   (gui 'query '(+QueryChart) *ROWS
>  '(goal
> (quote
>@Names
>(filter
>   '((X) X)
>  (mapcar
> '((X) (uppc (pack X)) )
> (split (chop *Tags) " ") ) )
>@Gen
>(mapcan
>   '((Nm) (list 'nm '+TagNm Nm))
>   '(filter  # Commented?
>  '((X) X)  #??
>  (mapcar
> '((X) (uppc (pack X)))
> (split (chop *Tags) " ") ) ) )
>(select (@@)
>   ((@Gen (nm +Tag) tsk))
>   (^ @
>  (fully
> '((Nm)
>(find
>   '((This) (or T (member Nm (: nm nm  # T?
>   (; (-> @@) tgs) ) )
> (-> @Names) ) ) ) ) )
>  1
>  '((This) (list This)) )
>
> (I assume the quotes, T etc. are temporary tests)
>
>
> > I get the tags as a list of space separated words in the *Tags
> > variable.
>
> That's all right, but better may be to use +ListTextField, it directly
> returns a
> list of strings:
>
>"Tags" (gui 'tags '(+ListTextField) '("," " ") 20)
>
>
> > I create the @Names and @Gen pilog variables using *Tags. As you
> > can see @Gen uses @Names inside it but I am not sure how to reuse the
> > definition of @Names inside the definition of @Gen. I tried wrapping the
> > whole "gui" call inside a let binding but that does not seem to work
> > either. What's the way out?
>
> Sorry, I don't understand this. In which way does @Gen "use" @Names?
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-12-04 Thread Alexander Burger
Hi Kashyap,

On Tue, Dec 03, 2019 at 07:48:58PM -0800, C K Kashyap wrote:
> I'll need a little bit more help with Pilog in QueryChart - In the code
> below,

Could you in the future provide code which is formatted in a more readable way?
It is very hard to decipher. Better no spaces between lines, and indentations
and parentheses more to the standard (see the output of 'pretty' and 'pp').

If I try to fix it manually, I get (hope I did not destroy anything):

   (diaform '(Dst)
  ( "--"
 "Name" (gui 'ttl '(+DbHint +Var +TextField) '(ttl > Task) '*Name 20)
 "Tags" (gui 'tags '(+Var +TextField) '*Tags 20)
 (searchButton '(init> (: home query))) )
  (gui 'query '(+QueryChart) *ROWS
 '(goal
(quote
   @Names
   (filter
  '((X) X)
 (mapcar
'((X) (uppc (pack X)) )
(split (chop *Tags) " ") ) )
   @Gen
   (mapcan
  '((Nm) (list 'nm '+TagNm Nm))
  '(filter  # Commented?
 '((X) X)  #??
 (mapcar
'((X) (uppc (pack X)))
(split (chop *Tags) " ") ) ) )
   (select (@@)
  ((@Gen (nm +Tag) tsk))
  (^ @
 (fully
'((Nm)
   (find
  '((This) (or T (member Nm (: nm nm  # T?
  (; (-> @@) tgs) ) )
(-> @Names) ) ) ) ) )
 1
 '((This) (list This)) )

(I assume the quotes, T etc. are temporary tests)


> I get the tags as a list of space separated words in the *Tags
> variable.

That's all right, but better may be to use +ListTextField, it directly returns a
list of strings:

   "Tags" (gui 'tags '(+ListTextField) '("," " ") 20)


> I create the @Names and @Gen pilog variables using *Tags. As you
> can see @Gen uses @Names inside it but I am not sure how to reuse the
> definition of @Names inside the definition of @Gen. I tried wrapping the
> whole "gui" call inside a let binding but that does not seem to work
> either. What's the way out?

Sorry, I don't understand this. In which way does @Gen "use" @Names?

☺/ A!ex

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


Re: +QueryChart without pilog

2019-12-03 Thread C K Kashyap
Hi Alex,
I'll need a little bit more help with Pilog in QueryChart - In the code
below, I get the tags as a list of space separated words in the *Tags
variable. I create the @Names and @Gen pilog variables using *Tags. As you
can see @Gen uses @Names inside it but I am not sure how to reuse the
definition of @Names inside the definition of @Gen. I tried wrapping the
whole "gui" call inside a let binding but that does not seem to work
either. What's the way out?

   (diaform '(Dst)

( "--"

 "Name" (gui 'ttl '(+DbHint +Var +TextField) '(ttl
+Task) '*Name 20)

 "Tags" (gui 'tags '(+Var +TextField) '*Tags 20)

 (searchButton '(init> (: home query)))

 )

(gui 'query '(+QueryChart) *ROWS

 '(goal

 (quote

 @Names (filter '((X) X) (mapcar '((X)
(uppc (pack X)))  (split (chop *Tags) " ")))

 @Gen (mapcan '((Nm) (list 'nm '+TagNm Nm))
'(filter '((X) X) (mapcar '((X) (uppc (pack X)))  (split (chop *Tags) "
"

 (select (@@)

 ((@Gen (nm +Tag) tsk))

   (^ @

   (fully

  '((Nm)

 (find

'((This) (or T (member
Nm (: nm nm

(; (-> @@) tgs) ) )

  (-> @Names) ) )

 )

  )

  )

  1

 '((This) (list This))

 )



On Fri, Nov 29, 2019 at 7:31 AM C K Kashyap  wrote:

> Oh yes! got it.
> Regards,
> Kashyap
>
> On Thu, Nov 28, 2019 at 11:10 PM Alexander Burger 
> wrote:
>
>> On Thu, Nov 28, 2019 at 01:30:26PM +0100, Alexander Burger wrote:
>> >(de f (Names)
>> >   (pilog
>> >  (quote
>> > @Names Names
>> > @Gen (mapcan '((Nm) (list 'nm '+TagVal Nm)) Names)
>> > (select (@Item)
>> >((@Gen (v +Tag) itm))
>> >...
>>
>> Haha, it just occurs to me that we made a stupid mistake!
>>
>> As we are searching for objects that have ALL names (i.e. an AND of all
>> names in
>> the list), searching the index multiple times (once for each element in
>> the
>> list) in very inefficient and unnecessary :)
>>
>> Instead, we can pick any element of the list, e.g. the CAR:
>>
>>(de f (Names)
>>   (pilog
>>  (quote
>> @Names Names
>> @Key (car Names)
>> (select (@Item)
>>((nm +TagVal @Key (v +Tag) itm))
>>...
>>
>> ☺/ A!ex
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>


Re: +QueryChart without pilog

2019-11-29 Thread C K Kashyap
Oh yes! got it.
Regards,
Kashyap

On Thu, Nov 28, 2019 at 11:10 PM Alexander Burger 
wrote:

> On Thu, Nov 28, 2019 at 01:30:26PM +0100, Alexander Burger wrote:
> >(de f (Names)
> >   (pilog
> >  (quote
> > @Names Names
> > @Gen (mapcan '((Nm) (list 'nm '+TagVal Nm)) Names)
> > (select (@Item)
> >((@Gen (v +Tag) itm))
> >...
>
> Haha, it just occurs to me that we made a stupid mistake!
>
> As we are searching for objects that have ALL names (i.e. an AND of all
> names in
> the list), searching the index multiple times (once for each element in the
> list) in very inefficient and unnecessary :)
>
> Instead, we can pick any element of the list, e.g. the CAR:
>
>(de f (Names)
>   (pilog
>  (quote
> @Names Names
> @Key (car Names)
> (select (@Item)
>((nm +TagVal @Key (v +Tag) itm))
>...
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-11-28 Thread Alexander Burger
On Thu, Nov 28, 2019 at 01:30:26PM +0100, Alexander Burger wrote:
>(de f (Names)
>   (pilog
>  (quote
> @Names Names
> @Gen (mapcan '((Nm) (list 'nm '+TagVal Nm)) Names)
> (select (@Item)
>((@Gen (v +Tag) itm))
>...

Haha, it just occurs to me that we made a stupid mistake!

As we are searching for objects that have ALL names (i.e. an AND of all names in
the list), searching the index multiple times (once for each element in the
list) in very inefficient and unnecessary :)

Instead, we can pick any element of the list, e.g. the CAR:

   (de f (Names)
  (pilog
 (quote
@Names Names
@Key (car Names)
(select (@Item)
   ((nm +TagVal @Key (v +Tag) itm))
   ...

☺/ A!ex

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


Re: +QueryChart without pilog

2019-11-28 Thread C K Kashyap
Super!
Regards,
Kashyap

On Thu, Nov 28, 2019 at 8:39 AM Alexander Burger 
wrote:

> On Thu, Nov 28, 2019 at 08:26:01AM -0800, C K Kashyap wrote:
> > I think having the filter in lisp still lets us take
> > advantage of +QueryChart's efficiency over large sets right?
>
> Yes, exactly. And it is faster than pure Pilog ;)
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-11-28 Thread Alexander Burger
On Thu, Nov 28, 2019 at 08:26:01AM -0800, C K Kashyap wrote:
> I think having the filter in lisp still lets us take
> advantage of +QueryChart's efficiency over large sets right?

Yes, exactly. And it is faster than pure Pilog ;)

☺/ A!ex

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


Re: +QueryChart without pilog

2019-11-28 Thread C K Kashyap
Thank you so much Alex,
This works for me!
I think having the filter in lisp still lets us take
advantage of +QueryChart's efficiency over large sets right?
Regards,
Kashyap

On Thu, Nov 28, 2019 at 4:37 AM Alexander Burger 
wrote:

> On Thu, Nov 28, 2019 at 11:45:23AM +0100, Alexander Burger wrote:
> >(de f (Names)
> >   (pilog
> >  (quote
> > @Names Names
> > @Gen (mapcan '((C) (list 'nm '+TagVal C)) Names)
> > (select (@Item)
> >((@Gen (v +Tag) itm))
> >(lst @Tag @Item tgs)
> >(val @Nm @Tag v nm)
> >(member @Nm @Names) ) )
> >  (print-item @Item) ) )
> >
> > But not what you want, right? It is still OR, not AND ...
>
> This is tough to do in Pilog. As Prolog is not more than a tree *search*
> engine,
> it is hard to prove that there is NO element in Names which canNOT be
> found in
> the tags names.
>
> It is surely possible, with 'or' and 'not' clauses plus cut operators, but
> I
> don't find it at the moment.
>
> So I would resort to Lisp in the filter:
>
>(de f (Names)
>   (pilog
>  (quote
> @Names Names
> @Gen (mapcan '((Nm) (list 'nm '+TagVal Nm)) Names)
> (select (@Item)
>((@Gen (v +Tag) itm))
>(^ @
>   (fully
>  '((Nm)
> (find
>'((This) (member Nm (: v nm)))
>(; (-> @Item) tgs) ) )
>  (-> @Names) ) ) ) )
>  (print-item @Item) ) )
>
>(f '("RED" "BLUE"))
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-11-28 Thread Alexander Burger
On Thu, Nov 28, 2019 at 11:45:23AM +0100, Alexander Burger wrote:
>(de f (Names)
>   (pilog
>  (quote
> @Names Names
> @Gen (mapcan '((C) (list 'nm '+TagVal C)) Names)
> (select (@Item)
>((@Gen (v +Tag) itm))
>(lst @Tag @Item tgs)
>(val @Nm @Tag v nm)
>(member @Nm @Names) ) )
>  (print-item @Item) ) )
> 
> But not what you want, right? It is still OR, not AND ...

This is tough to do in Pilog. As Prolog is not more than a tree *search* engine,
it is hard to prove that there is NO element in Names which canNOT be found in
the tags names.

It is surely possible, with 'or' and 'not' clauses plus cut operators, but I
don't find it at the moment.

So I would resort to Lisp in the filter:

   (de f (Names)
  (pilog
 (quote
@Names Names
@Gen (mapcan '((Nm) (list 'nm '+TagVal Nm)) Names)
(select (@Item)
   ((@Gen (v +Tag) itm))
   (^ @
  (fully
 '((Nm)
(find
   '((This) (member Nm (: v nm)))
   (; (-> @Item) tgs) ) )
 (-> @Names) ) ) ) )
 (print-item @Item) ) )

   (f '("RED" "BLUE"))

☺/ A!ex

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


Re: +QueryChart without pilog

2019-11-28 Thread Alexander Burger
Oops, wait!

On Thu, Nov 28, 2019 at 10:56:56AM +0100, Alexander Burger wrote:
>(de f (Names)
>   (pilog
>  (quote
> @Names Names
> @Gen (mapcan '((C) (list 'nm '+TagVal C)) Colors)
> (select (@Item)
>((@Gen (v +Tag) itm))
>(lst @Nm @Item tgs v nm)
>(member @Nm @Names) ) )
>  (print-item @Item) ) )

This has a mistype (Colors instead of Names).
Also, we need 'lst' plus 'val'.

Better is:

   (de f (Names)
  (pilog
 (quote
@Names Names
@Gen (mapcan '((C) (list 'nm '+TagVal C)) Names)
(select (@Item)
   ((@Gen (v +Tag) itm))
   (lst @Tag @Item tgs)
   (val @Nm @Tag v nm)
   (member @Nm @Names) ) )
 (print-item @Item) ) )

But not what you want, right? It is still OR, not AND ...

☺/ A!ex

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


Re: +QueryChart without pilog

2019-11-28 Thread Alexander Burger
On Thu, Nov 28, 2019 at 10:44:15AM +0100, Alexander Burger wrote:
> I would prepare the generator clauses as a Pilog variable, to build them at
> runtime, and then use the member/2 predicate in the filter clause to check for
> membership in the list of colors.

Could not resist :) This works:

   (de f (Names)
  (pilog
 (quote
@Names Names
@Gen (mapcan '((C) (list 'nm '+TagVal C)) Colors)
(select (@Item)
   ((@Gen (v +Tag) itm))
   (lst @Nm @Item tgs v nm)
   (member @Nm @Names) ) )
 (print-item @Item) ) )

   (f '("RED" "BLUE"))

☺/ A!ex

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


Re: +QueryChart without pilog

2019-11-28 Thread Alexander Burger
Hi Kashyap,

> Hurray!!!

:)


> 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?

Yes, similar. The +CuSu case does:

1. fetch all +CuSu objects from the 'nm' tree whose names match the string in
   @Sup
2. use each object to index into the 'sup' tree (supplier) of items, to get
   these item objects
3. Index with the items into the position tree
4. Follow the joint from each found position to get its order object


(nm +TagVal @Col1  nm +TagVal) is a bit truncated.

The full generator was

   ((nm +TagVal @Col1  nm +TagVal @Col2) (v +Tag) itm)

It traverses the 'nm' tree *two* times, first for color 1 and then for color 2.
The found +TagVal objects are used to index into the 'v' tree of +Tag.


> 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.

> (de MakeQ Tags

Better use (de MakeQ @ ..) or (de MakeQ (Tags) ..) to get evaluated arguments or
argument list rspectively.


> (let (
> Col '( (N) (intern (pack '@Col N)))

'intern' is not needed and not recommended.

I would prepare the generator clauses as a Pilog variable, to build them at
runtime, and then use the member/2 predicate in the filter clause to check for
membership in the list of colors.

☺/ A!ex




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


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
>


Re: +QueryChart without pilog

2019-11-26 Thread Alexander Burger
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


Re: +QueryChart without pilog

2019-11-26 Thread C K Kashyap
Hey Alex,
It seems to work as expected using collects :) Here's the complete program
- it prints out ITEM1 and ITEM6 as expected.

(call "rm" "-f" "test.db")

(class +Item +Entity)
(rel ttl (+IdxFold +String))
(rel tgs (+List +Joint) itm (+Tag))
(rel sts (+IdxFold +String))

(class +Tag +Entity)
(rel itm (+Joint) tgs (+Item))
(rel v (+Ref +Link) NIL +TagVal)

(class +TagVal +Entity)
(rel nm (+IdxFold +String))

(de print-item (This)
(prinl (: ttl) ": " (: sts) " [" (glue ", " (mapcar '( (This) (get (:
v) 'nm)) (: tgs) ) ) "]" )
)

(pool "test.db")

(setq RED (new! '(+TagVal) 'nm "RED"))
(setq BLUE (new! '(+TagVal) 'nm "BLUE"))

(de new-item (Ttl Sts Tgs)
(let N (new! '(+Item) 'ttl Ttl 'sts Sts)
 (for Tg Tgs
  (put!> N 'tgs (new! '(+Tag) 'v Tg 'itm N))
 )
)
)

(new-item "ITEM1" "OPEN" (list RED BLUE))
(new-item "ITEM2" "CLOSED" (list RED))
(new-item "ITEM3" "OPEN" (list BLUE))
(new-item "ITEM4" "OPEN" (list))
(new-item "ITEM5" "CLOSED" (list))
(new-item "ITEM6" "OPEN" (list BLUE RED))
(new-item "ITEM7" "OPEN" (list RED))

(commit)

(let (RED (db 'nm '+TagVal "RED")
  BLUE (db 'nm '+TagVal "BLUE"))
  (setq L1 (collect 'v '+Tag RED RED 'itm))
  (setq L2 (collect 'v '+Tag BLUE BLUE 'itm)))

(for I (sect L1 L2)
 (print-item I))

On Tue, Nov 26, 2019 at 1:52 PM Alexander Burger 
wrote:

> On Tue, Nov 26, 2019 at 01:13:09PM -0800, C K Kashyap wrote:
> > Hey Alex,
> > What I need is an "and" - with collects, I do a (sect of L1 L2) ... I
> tried
> > a bunch but cant seem to get "and" working -
> > I need the items that are "RED" and "BLUE" :(
>
> Hmm, isn't that impossible? In your model, a tag has a *single* link to a
> TagVal, so it has *one* color and cannot have red AND blue at the same time
>
>(class +Tag +Entity)
>(rel itm (+Joint) tgs (+Item))
>(rel v (+Ref +Link) NIL +TagVal)
>
>(class +TagVal +Entity)
>(rel nm (+IdxFold +String))
>
> so
>
> > >> >   (setq L1 (collect 'v '+Tag RED RED 'itm))
> > >> >   (setq L2 (collect 'v '+Tag BLUE BLUE 'itm)))
> > >> > (sect L1 L2) --> this is what I want
>
> the section of L1 and L2 will always be empty, no?
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-11-26 Thread Alexander Burger
On Tue, Nov 26, 2019 at 01:13:09PM -0800, C K Kashyap wrote:
> Hey Alex,
> What I need is an "and" - with collects, I do a (sect of L1 L2) ... I tried
> a bunch but cant seem to get "and" working -
> I need the items that are "RED" and "BLUE" :(

Hmm, isn't that impossible? In your model, a tag has a *single* link to a
TagVal, so it has *one* color and cannot have red AND blue at the same time

   (class +Tag +Entity)
   (rel itm (+Joint) tgs (+Item))
   (rel v (+Ref +Link) NIL +TagVal)

   (class +TagVal +Entity)
   (rel nm (+IdxFold +String))

so

> >> >   (setq L1 (collect 'v '+Tag RED RED 'itm))
> >> >   (setq L2 (collect 'v '+Tag BLUE BLUE 'itm)))
> >> > (sect L1 L2) --> this is what I want

the section of L1 and L2 will always be empty, no?

☺/ A!ex

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


Re: +QueryChart without pilog

2019-11-26 Thread C K Kashyap
Hey Alex,
What I need is an "and" - with collects, I do a (sect of L1 L2) ... I tried
a bunch but cant seem to get "and" working -
I need the items that are "RED" and "BLUE" :(
Perhaps I have to adjust the ER to achieve this?
regards,
Kashyap

On Tue, Nov 26, 2019 at 7:42 AM C K Kashyap  wrote:

> Thanks Alex,
> I'll try it out.
> Regards,
> Kashyap
>
> On Mon, Nov 25, 2019 at 11:24 PM Alexander Burger 
> wrote:
>
>> Hi Kashyap,
>>
>> > Here's a new problem - as per the previous conversation, it seems that I
>> > could use "collect" to get the items that I am interested in.
>> >
>> > (let (RED (db 'nm '+TagVal "RED")
>> >   BLUE (db 'nm '+TagVal "BLUE"))
>> >   (setq L1 (collect 'v '+Tag RED RED 'itm))
>> >   (setq L2 (collect 'v '+Tag BLUE BLUE 'itm)))
>> > (sect L1 L2) --> this is what I want
>> > It looks like the step> method of QueryChart calls "prove" which tells
>> me
>> > that it can only do pilog.
>>
>> Yes +QueryChart needs Pilog. In general, Pilog is also recommended if the
>> possible result set may be large and long 'collect'ed lists become
>> inefficient.
>>
>> So the 'v' index of '+Tag' needs to be traversed twice, once for the RED
>> object
>> and once for BLUE.
>>
>> To do the above in Pilog, you need a combined generator and a filter with
>> 'or':
>>
>>...
>>@Col1 (db 'nm '+TagVal "RED")
>>@Col2 (db 'nm '+TagVal "BLUE")
>>...
>>(select (@Tag)
>>   (...
>>  ((v +Tag @Col1  v +Tag @Col2))  # Traverse tree twice
>>  ... )
>>   (or ((same @Col1 @Tag v)) ((same @Col2 @Tag v)))  # filter with OR
>>   ... )
>>
>> or generate directly
>>
>>...
>>@Col1 "RED"
>>@Col2 "BLUE"
>>...
>>(select (@Tag)
>>   (...
>>  ((nm +TagVal @Col1  nm +TagVal @Col2) (v +Tag))
>>  ... )
>>   (or ((same @Col1 @Tag v nm)) ((same @Col2 @Tag v nm)))
>>   ... )
>>
>> (Not tested!)
>>
>> ☺/ A!ex
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>


Re: +QueryChart without pilog

2019-11-26 Thread C K Kashyap
Thanks Alex,
I'll try it out.
Regards,
Kashyap

On Mon, Nov 25, 2019 at 11:24 PM Alexander Burger 
wrote:

> Hi Kashyap,
>
> > Here's a new problem - as per the previous conversation, it seems that I
> > could use "collect" to get the items that I am interested in.
> >
> > (let (RED (db 'nm '+TagVal "RED")
> >   BLUE (db 'nm '+TagVal "BLUE"))
> >   (setq L1 (collect 'v '+Tag RED RED 'itm))
> >   (setq L2 (collect 'v '+Tag BLUE BLUE 'itm)))
> > (sect L1 L2) --> this is what I want
> > It looks like the step> method of QueryChart calls "prove" which tells me
> > that it can only do pilog.
>
> Yes +QueryChart needs Pilog. In general, Pilog is also recommended if the
> possible result set may be large and long 'collect'ed lists become
> inefficient.
>
> So the 'v' index of '+Tag' needs to be traversed twice, once for the RED
> object
> and once for BLUE.
>
> To do the above in Pilog, you need a combined generator and a filter with
> 'or':
>
>...
>@Col1 (db 'nm '+TagVal "RED")
>@Col2 (db 'nm '+TagVal "BLUE")
>...
>(select (@Tag)
>   (...
>  ((v +Tag @Col1  v +Tag @Col2))  # Traverse tree twice
>  ... )
>   (or ((same @Col1 @Tag v)) ((same @Col2 @Tag v)))  # filter with OR
>   ... )
>
> or generate directly
>
>...
>@Col1 "RED"
>@Col2 "BLUE"
>...
>(select (@Tag)
>   (...
>  ((nm +TagVal @Col1  nm +TagVal @Col2) (v +Tag))
>  ... )
>   (or ((same @Col1 @Tag v nm)) ((same @Col2 @Tag v nm)))
>   ... )
>
> (Not tested!)
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: +QueryChart without pilog

2019-11-25 Thread Alexander Burger
Hi Kashyap,

> Here's a new problem - as per the previous conversation, it seems that I
> could use "collect" to get the items that I am interested in.
> 
> (let (RED (db 'nm '+TagVal "RED")
>   BLUE (db 'nm '+TagVal "BLUE"))
>   (setq L1 (collect 'v '+Tag RED RED 'itm))
>   (setq L2 (collect 'v '+Tag BLUE BLUE 'itm)))
> (sect L1 L2) --> this is what I want
> It looks like the step> method of QueryChart calls "prove" which tells me
> that it can only do pilog.

Yes +QueryChart needs Pilog. In general, Pilog is also recommended if the
possible result set may be large and long 'collect'ed lists become inefficient.

So the 'v' index of '+Tag' needs to be traversed twice, once for the RED object
and once for BLUE.

To do the above in Pilog, you need a combined generator and a filter with 'or':

   ...
   @Col1 (db 'nm '+TagVal "RED")
   @Col2 (db 'nm '+TagVal "BLUE")
   ...
   (select (@Tag)
  (...
 ((v +Tag @Col1  v +Tag @Col2))  # Traverse tree twice
 ... )
  (or ((same @Col1 @Tag v)) ((same @Col2 @Tag v)))  # filter with OR
  ... )

or generate directly

   ...
   @Col1 "RED"
   @Col2 "BLUE"
   ...
   (select (@Tag)
  (...
 ((nm +TagVal @Col1  nm +TagVal @Col2) (v +Tag))
 ... )
  (or ((same @Col1 @Tag v nm)) ((same @Col2 @Tag v nm)))
  ... )

(Not tested!)

☺/ A!ex

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