dcg
Rewrite recursive sicstus prolog function
My goal is to have this input: L = [a,b,c], build_tree(L,T). With this output: L = [1,30,kth,5], T = b(l(a),b(l(b),b(l(c)))) ?[详细]
2023-04-05 02:34 分类:问答Using phrase_from_file to read a file's lines
I\'ve been trying to parse a file containing lines of integers using phrase_from_file with the grammar rules[详细]
2023-03-23 11:05 分类:问答Prolog DCGs Multiple Features?
From what I understand, in Prolog you capture features while parsing 开发者_JS百科like so: foo(feature(X)) --> [X], bar.[详细]
2023-03-16 20:15 分类:问答Recursive Prolog predicate for reverse / palindrome
Can I get a recursive Prolog predicate having two arguments, called reverse, which returns the inverse of a list:[详细]
2023-03-14 13:36 分类:问答Avoid linear cost of append/3 in Prolog
Let\'s assume that we\'re reading from standard input and building a list of all the开发者_StackOverflow中文版 lines that have been read.In the end, we need to display those lines, separated by commas[详细]
2023-03-12 00:46 分类:问答Parsing in prolog
run([H|T]) --> num(H),run(T). run([T]) --> num(T). num(increase) --> [increase],{write(1),nl}.[详细]
2023-03-10 16:52 分类:问答Given a substitution S and list Xs, how to apply S to Xs
Suppose I have a substitution S and list Xs, where each variable occurring in Xs also occurs in S. How would I find the list S(Xs), i.e., the list obtained by applying the substitution S to the list X[详细]
2023-03-10 09:14 分类:问答Debugging in SWI-prolog - unbound variables
Consider the following Prolog code.It edits lines of a particular type in its input and prints out the remaining lines w/o any change.It uses a DCG called rule which isn\'t included below, since it\'s[详细]
2023-03-10 04:46 分类:问答Prolog Question - Simple Grammar Implementation
If I have the following grammar: S → ε S → a S b S How do I implement it in Prolog? I tried this: isMatched([]).[详细]
2023-03-05 19:03 分类:问答Prolog as a DSL to generate perl code?
Does anyone know of any examples of code written in prolog to implement a DSL to generate开发者_StackOverflow社区 perl code?DCGs might be an excellent choice![详细]
2023-02-12 08:13 分类:问答