Re: The order of arguments in diff
On Sat, Nov 26, 2016 at 09:05:44PM -0500, Bruno Franco wrote: > I was trying out the diff function and I noticed something: > > : (diff '(1 2 3 4) '(3 4)) > -> (1 2) > > but > > : (diff '(3 4) '(1 2 3 4)) > -> NIL > > I think this means that there is an order to the arguments of diff, where It is analogous to the arithmetic difference, where A - B is not the same as B - A. > the second argument must be the shortest. This is not the case. The length is not relevant: : (diff (1 2 3) (8 6 4 2)) -> (1 3) > I also tried this: > > : (diff (1 2 3 4) 2) > -> (1 3 4) > > So, why does diff work even if the second argument isn't a list? This is a result of how 'diff' is implemented internally. It takes all elements into account, I think it is a welcome feature. Note that this also works: : (diff (1 2 3) (1 . 2)) -> (3) ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: solving for pilog variables
Hi Dean, > #(prove (goal '(equal 3 @X) )) 'goal' needs a list of clauses: : (prove (goal '((equal 3 @X -> ((@X . 3)) > #: (prove (goal '( (equal 3 @X) (member @X (1 2 4)) ))) > #-> NIL > #: (prove (goal '( (equal 3 @X) (member @X (1 2 3)) ))) > #-> ((@X . 3)) OK > #(prove (goal '( > #(equal @Profit (- @Sales @Cogs)) Did you define a '-' predicate? ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Unsubscribe
It's OK...I'm still subscribed with another address. On Nov 26, 2016 9:13 PM, "Bruno Franco"wrote: > I was trying out the diff function and I noticed something: > > : (diff '(1 2 3 4) '(3 4)) > -> (1 2) > > but > > : (diff '(3 4) '(1 2 3 4)) > -> NIL > > I think this means that there is an order to the arguments of diff, where > the second argument must be the shortest. > I wanted to ask if this was correct, and also why was it chosen to be > this way. > > I also tried this: > > : (diff (1 2 3 4) 2) > -> (1 3 4) > > So, why does diff work even if the second argument isn't a list? > > I ran (doc 'diff), and though it explained how diff worked, it didn't > answer either of my questions. I'd be grateful for any answers you can give > me, as well as pointers to any document or reference on the internet that > explains these issues. > > Thank you very much. >
The order of arguments in diff
I was trying out the diff function and I noticed something: : (diff '(1 2 3 4) '(3 4)) -> (1 2) but : (diff '(3 4) '(1 2 3 4)) -> NIL I think this means that there is an order to the arguments of diff, where the second argument must be the shortest. I wanted to ask if this was correct, and also why was it chosen to be this way. I also tried this: : (diff (1 2 3 4) 2) -> (1 3 4) So, why does diff work even if the second argument isn't a list? I ran (doc 'diff), and though it explained how diff worked, it didn't answer either of my questions. I'd be grateful for any answers you can give me, as well as pointers to any document or reference on the internet that explains these issues. Thank you very much.
solving for pilog variables
I'm quite shaky on this so started with a simple example and added stuff. Unfortunately, I've come off the rails somewhere but am not sure wjy or what to do about it. Any advice...much appreciated. #(prove (goal '(equal 3 @X) )) #: (prove (goal '( (equal 3 @X) (member @X (1 2 4)) ))) #-> NIL #: (prove (goal '( (equal 3 @X) (member @X (1 2 3)) ))) #-> ((@X . 3)) #(prove (goal '( #(equal @Profit (- @Sales @Cogs)) #(member @Profit (100 200 300)) #(member @Sales (100 250 300)) #(member @Cogs (100 50 300)) ## ))) (prove (goal '( (equal @Profit (- @Sales @Cogs)) (member @Profit (100 200 300)) (member @Sales (100 250 300)) (member @Cogs (100 50 300)) )))
Subscribe
Hello "Fabian Boucsein":-) You are now subscribed -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe