Re: Date query question

2016-12-27 Thread Henrik Sarvell
Yes, like I thought, so I doubt that it will be an improvement over the
current state which looks like this:

## We want all projects that are NOT outside of the range, ie:
## 1.) End date is lower than the start date of the range.
## 2.) Start date is higher than the end date of the range.
## Therefore we generate all projects whose:
## 1.) Start date is smaller than the end date of the range.
## 2.) End date is larger than the start date of the range.
(dm getCurrent> (Sdate Edate)
   (solve
  (quote
 @Rng1 (cons NIL Edate)# The first range
 @Rng2 (cons Sdate T)  # The second range
 (select (@Proj)
((sDate +Proj @Rng1) (eDate +Proj @Rng2)) # Search two indexes
in parallel
(range @Rng1 @Proj sDate)  # Check ranges
(range @Rng2 @Proj eDate) ) )
  @Proj ) )

The above works, tested 100%, it looks like it's going to scan the whole
database though in the generate clauses, which means collect on id with
subsequent list filter is probably just as fast, or perhaps not?




On Tue, Dec 27, 2016 at 8:27 AM, Alexander Burger 
wrote:

> On Mon, Dec 26, 2016 at 11:19:02PM +0100, Henrik Sarvell wrote:
> > If I do the relations with the +UB index and put 2016-10-01 as the start
> > date and 2016-10-20 as the end date for a specific project, do I get that
> > project in my result set if I do the collect with sdate 2016-10-15 and
> end
> > date 2016-11-15?
>
> > > >(rel sDate (+UB +Aux +Ref +Date) (eDate))
> > > >(rel eDate (+Date))
> > > >
> > > > Then a 'collect' would find the range directly:
> > > >
> > > >(collect 'sDate '+Proj (list Sdate Sdate) (list Edate Edate))
>
> No. Consider eDate and sDate as coordinates in a 2-dimensional space,
> where a
> project is a point in that space.
>
> So you need to collect all projects with sDate at least in the range
> (2016-10-01 . 2016-10-01) and eDate at least in the range
> (2016-10-20 . 2016-10-20) to include the above project.
>
> A collection with the ranges (2016-10-1 . 2016-10-31) and (2016-11-1 .
> 2016-11-30), for example, would return all projects which started in
> October AND
> ended in November 2016.
>
> The ranges are inclusive btw.
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Unsubscribe

2016-12-27 Thread Atte Hinkka
Good bye Atte Hinkka  :-(
You are now unsubscribed


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


Re: Wiki search for 'NIL'

2016-12-27 Thread Michel Pelletier
Martin Porter keeps a list of common english stop words that is frequently
used to improve search results:

http://snowball.tartarus.org/algorithms/english/stop.txt

On Tue, Dec 27, 2016 at 6:31 AM, Erik Gustafson 
wrote:

> Hi Alex,
>
> As we see, it indexes only words which have a length of 4 characters or
> more.
>
> The reason is to decrease the total index size (which may in fact not be
> critical) and to avoid noise like "a", "the" and "and". This function
> could be
> made more intelligent.
>
>
> Ahh, that makes sense. I may or may not play around with some changes on a
> local copy. Might save a newcomer or two some time down the road; not
> exactly mission critical though.
>
>


Re: (= code data)

2016-12-27 Thread Rowan Thorpe
On 27 December 2016 at 20:03, Lindsay John Lawrence
 wrote:
> This little gem was an epiphany in my understanding of the equivalence
> of code and data in lisp.
>
> https://rosettacode.org/wiki/Jump_anywhere#PicoLisp

:-) Another nice/simple way to demo Picolisp's homoiconicity is by
implementing "docstrings"
within a small function :-) See here for an example:

 
https://github.com/rowanthorpe/taskwrangle/blob/b14e2fe47a9e03f025442941b2867eb122cefa8b/lib/libtaskwrangle.l#L252

-- 
Rowan Thorpe
PGP fingerprint:
 BB0A 0787 C0EE BDD8 7F97  3D30 49F2 13A5 265D CCBD
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: (= code data)

2016-12-27 Thread Joh-Tob Schäg
Classic
Am 27.12.2016 19:08 schrieb "Lindsay John Lawrence" <
lawrence.lindsayj...@gmail.com>:

> I've been working my way through the Rosetta code examples as a way to
> build fluency in picolisp. This little gem was an epiphany in my
> understanding of the equivalence of code and data in lisp.
>
> https://rosettacode.org/wiki/Jump_anywhere#PicoLisp
>
> (de foo (N)
>(prinl "This is 'foo'")
>(printsp N)
>(or (=0 (dec 'N)) (run (cddr foo))) )
>
>
> /Lindsay
> p.s. studying the rosetta code examples has been time well spent.
>
>


(= code data)

2016-12-27 Thread Lindsay John Lawrence
I've been working my way through the Rosetta code examples as a way to
build fluency in picolisp. This little gem was an epiphany in my
understanding of the equivalence of code and data in lisp.

https://rosettacode.org/wiki/Jump_anywhere#PicoLisp

(de foo (N)
   (prinl "This is 'foo'")
   (printsp N)
   (or (=0 (dec 'N)) (run (cddr foo))) )


/Lindsay
p.s. studying the rosetta code examples has been time well spent.


Functional Arguments

2016-12-27 Thread Alexander Burger
Hi all,

while talking about 'set' and 'setq', let me clarify another issue. Quite often
I see here - or in IRC - expressions like

   (mapc 'set '(A B C) (1 2 3))

or

   (mapcar 'inc (4 5 6))

While this certainly works, it is actually wrong, or at least unnecessary.


The mapping functions want a *functional* first argument. If you look up in the
reference (under "Evaluation", doc/ref.html#ev), it says that a function is
either a number (a function pointer) or a cell (with parameter(s) in the CAR and
a 'prg' body in the CDR).

However, the above expressions pass a *symbol* to the mapping functions. So just

   (mapc set '(A B C) (1 2 3))
or
   (mapcar inc (4 5 6))

would be fine, because the first arguments are evaluated, resulting in proper
numbers.


The quoted calls (resulting in symbols) happen to work just due to a lucky
coincidence:

When PicoLisp evaluates a function call, it tries to be tolerant. Instead of
throwing an error when hitting a symbol, it *evaluates* that symbol (or any
expressions in general which show up, until it gets to a proper function. For
example

   (de square (N)
  (* N N) )

   (setq
  F 'square )
  L '(line square circle) )

   : (F 7)
   -> 49

   : ((cadr L) 7)
   -> 49

   : ((val (cadr L)) 7)
   -> 49


One more note: In case of *message* calls on objects you *must* pass a symbol.
They need a symbol to locate the right method in the class hierarchy

   (mapc 'lose> (collect 'key '+Cls))

so here the quote is correct.

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


Re: Wiki search for 'NIL'

2016-12-27 Thread Erik Gustafson
Hi Alex,

As we see, it indexes only words which have a length of 4 characters or
more.

The reason is to decrease the total index size (which may in fact not be
critical) and to avoid noise like "a", "the" and "and". This function could
be
made more intelligent.


Ahh, that makes sense. I may or may not play around with some changes on a
local copy. Might save a newcomer or two some time down the road; not
exactly mission critical though.


Re: What is the difference between set and setq?

2016-12-27 Thread Erik Gustafson
It is the *function* call overhead, which is relatively expensive. [...]


Thanks Alex, this is great. I'll add to the wiki article later today.


Re: What is the difference between set and setq?

2016-12-27 Thread Alexander Burger
On Tue, Dec 27, 2016 at 08:49:10AM +0100, Alexander Burger wrote:
> > > On Mon, Dec 26, 2016 at 10:25 PM, Erik Gustafson <
> Thanks Erik for the great explanation and the article!

I feel I should also mention that the purpose of

   (setq A 'value)

versus

   (set 'A 'value)

is not at all to avoid some typing. In fact, the overall numbers of characters
is the same ;)


It is the *function* call overhead, which is relatively expensive. As you know,
the quote character is a read macro, so that

   (set 'A 'value)

expands to

   (set (quote . A) (quote . value))

immediately when the expression is read. The evaluation of the arguments to
'set' thus triggers the analysis of the expression (quote . A) followed by the
'quote' call.

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


Re: Wiki search for 'NIL'

2016-12-27 Thread Alexander Burger
Hi Erik,

> I was looking for the 'Dual Nature of NIL' article and noticed that using
> the wiki search functionality to search for 'NIL' yeilds... well, nil. No
> results.
> 
> Kind of amusing and maybe not terribly surprising.

Indeed! :)

The reason is simple: The '+MupIdx' index class in "wiki/er.l" uses
'foldedWords' to dissect the text:

   (de foldedWords (Mup)
  (when Mup
 (uniq
(filter '((W) (>= (length W) 4))
   (splitWords (in (blob Mup 'txt) (till))) ) ) ) )

As we see, it indexes only words which have a length of 4 characters or more.

The reason is to decrease the total index size (which may in fact not be
critical) and to avoid noise like "a", "the" and "and". This function could be
made more intelligent.

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