Alex, Thank you as always. Very helpful
By the way, I am reading "Programming in Prolog" by Clocksin/Mellish per the recommendation on the reference page. I have spent a fair amount of time reading various prolog tutorials and this book is really clicking for me. Thanks again for the recommendation. For the list, I have found these lectures to be really good too: http://vimeo.com/user8713508/videos . It filled in alot of the "why" that was left uncovered in many of the tutorials. The book is doing a great job as well. Joe On Nov 22, 2012 2:56 AM, "Alexander Burger" <a...@software-lab.de> wrote: > Hi Joe, > > > (be add1-or-double (@X @Num) > > (member @X (1 2 3 4)) > > (@Ans + 1 (-> @X)) > > (@Ans2 * 2 (-> @X)) > > (or ((equal @Num @Ans)) ((equal @Num @Ans2)))) > > > > (? (add1-or-double @X 4)) > > @X=2 @X=3: > > OK > > > > If I try this: > > > > (be add1-or-double (@X @Num) > > # (member @X (1 2 3 4)) > > (@X range 1 100) > > 'range/3' is a predicate, not a generator. You can use it only for > range checks like: > > : (? (range (1 . 5) 3)) > -> T > : (? (range (1 . 5) 7)) > -> NIL > > Its main purpose is for database queries, to be used as a filter for > numeric or date values. > > > Instead, you might consider using 'for/2' > > (be add1-or-double (@X @Num) > (for @X 4) > (@Ans + 1 (-> @X)) > (@Ans2 * 2 (-> @X)) > (or ((equal @Num @Ans)) ((equal @Num @Ans2))) ) > > > To generate an unlimited supply of numbers, you could write > > (be number (@N) > (@C box 0) > (repeat) > (@N inc (-> @C)) ) > > (be add1-or-double (@X @Num) > (number @X) > (@Ans + 1 (-> @X)) > (@Ans2 * 2 (-> @X)) > (or ((equal @Num @Ans)) ((equal @Num @Ans2))) ) > > Note, however, that this won't terminate. > > ♪♫ > - Alex > -- > UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >