Re: "dict"ionary typing?
Michael Hendricks <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAFHuXubeqGmbR+HZC4O-ho=gVyz8fj1c0PCZmskSuNSYpK9LXA@mail.gmail.com> |
Hi Shon, On Thu, Dec 5, 2013 at 7:48 AM, Shon Feder <[email protected]> wrote: > I believe that what you are describing, Michael, is *exactly* what Carlo > Capelli announced with his `lifter` package, in the "Functional Syntax" > thread yesterday: > Yes. I posted my thoughts to an issue on https://github.com/mndrix/func a few days before I first heard of Carlo's work. I was reassured that he and I had come to the same solution. I plan to implement this for library(func) tomorrow. Probably using ~ instead of º since the latter is not readily available on my keyboard :-) > I have used the module (https://github.com/CapelliC/prolog-snippets) and > I find it quite interesting. Carlo's approach is interesting for exactly > the reasons you note. > If you haven't yet, you might also look at the "func" pack at http://www.swi-prolog.org/pack/list?p=func Many of your ideas about predicates as functions are implemented there. You might also like the "function_expansion" pack at http://www.swi-prolog.org/pack/list?p=function_expansion which makes it easy to create additional function-like behavior. > With `lifter`, the clause > > longer(A,B) :- > length(A,º) > length(B,º). > With func, this is written: longer(A,B) :- length $ A > length $ B It has the same expansion as the other implementations you mention. $/2 works with any predicate, using the final argument as the output. It behaves similarly to ".of" which you describe. func also lets you compose predicates as if they were functions. It's really just an extension of your idea that we can use the final argument of a predicate as its output. For example, we might craft our own version of atom_length/2 with % apply atom_codes/2 and then length/2 AtomLength = length of atom_codes then we might call(AtomLength, hello, N) and see N=5. Or using sugar writeln(AtomLength $ hello) to display "5". In any case, I have really enjoyed reading these discussions recently ... > Me too. Thank you for contributing your thoughts to the discussion. -- Michael -------------- next part -------------- HTML attachment scrubbed and removed _______________________________________________ SWI-Prolog mailing list [email protected] https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog