Replies: 4 comments 9 replies
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
Probably relevant: #2260 |
Beta Was this translation helpful? Give feedback.
-
|
As a Scryer/Prolog outsider (only a very naive user), I tend to use this "bottom-up" definition: with something like this (because we can have more than one Yes, of course, I was using DCGs (a "simpler", more top-down definition) for Originally I wanted to create a (pure) predicate for splitting a string ("string to words") that would work in Scryer and Trealla without consuming too much memory or being very slow with a "long" input text, and still being relatively simple (for me to create, because I use only "simple" Prolog). The "bottom-up" idea (constructing a set by mathematical induction) helped me to think in a new way about Prolog, and about programming in general (note: it's orthogonal/independent to the idea of top-down/bottom-up decomposition of a problem at hand). If nothing else, the idea re-invented Prolog and logic programming for me... In these days I realized that I'm not the right person for Prolog, but it was a great adventure and very, very useful, important to and for me (thank you all), even if I will not use Prolog. |
Beta Was this translation helpful? Give feedback.
-
|
So I do think there is some nuanced behavior that should have been obvious in retrospect. ?- maplist(phrase((..., [W])), [[1,2,3], [5,4,3]]).
W = 3
; false.
?- maplist(phrase((..., [W])), [[1,2,3], "hey"]).
false.In the first case, In the example presented, there are other ways to backtrack over Everything else was just me flailing and misunderstanding the problem! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am toying around with using DCGs as regular expressions in a command line tool thanks to some interesting comments regarding DCGs lately by @UWN and @hurufu. I wanted to split the stdin into lines and then process the lines with a DCG from the
argv/1, but I'm running into strange behavior when I try to usemaplist/3as a secondary processing step withphrase/3!Is this a bug or some nuanced Prolog behavior that I'm not fully understanding?
Below I show that
parse_lines//1is nominally working, and that neitherphrase/3normaplist/3fully explain the behavior I am seeing unless used together.Beta Was this translation helpful? Give feedback.
All reactions