meta-predicate Questions

2

Solved

I normally was able to figure out some usages of Lambda with maplist, but in general have hard time using lambda in prolog. It is probably because it differ from other languages, because of unifica...
Precocity asked 24/1, 2021 at 21:1

2

Solved

Are Hilog terms (i.e. compounds having as functors arbitrary terms) still regarded as a powerful feature in XSB Prolog (or any other Prolog) ? Are there many XSB projects currently using this featu...
Howlend asked 18/3, 2013 at 9:10

1

Solved

?- assertz(:- module(foo1, [f/1])). true. ?- foo1:assertz(f(1)). true. ?- foo1:f(1). true. ?- foo2:f(1). Correct to: "foo1:f(1)"? no ERROR: Undefined procedure: foo2:f/1 ERROR: In: ERROR: [8] fo...
Wengert asked 30/4, 2020 at 3:37

1

I am trying to define a relation callto_status(Goal, Status) that always succeeds and unifies Status according to the result of calling Goal (in other words, I would like to implement a reified ver...
Tal asked 13/2, 2019 at 19:48

6

Solved

I'm currently working on a very short project on Prolog, and just got stuck trying to apply a "filter" I have created to a list. I have what you could call the filter ready, but I can't apply it. I...
Zollie asked 18/11, 2008 at 6:24

1

Solved

Suppose I want to write a custom operator for composing DCG rules in a way that would otherwise be repetitive. For example, suppose I had I a DCG, ws such that: ws --> []. ws --> " ", ws. ...
Azotemia asked 27/7, 2018 at 17:30

3

This is a question provoked by an already deleted answer to this question. The issue could be summarized as follows: Is it possible to fold over a list, with the tail of the list generated while...
Renayrenckens asked 16/9, 2016 at 12:12

3

Solved

Given the following facts in a database: foo(a, 3). foo(b, 2). foo(c, 4). foo(d, 3). foo(e, 2). foo(f, 6). foo(g, 3). foo(h, 2). I want to collect all first arguments that have the smallest seco...

1

Solved

Using SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.5), we proceed step by step: Define dcg nonterminal a//1 in module dcgAux (pronounced: "di-SEE-goh"): :- module(dcgAux,[a//1]). a(0) --> ...
Insupportable asked 21/8, 2015 at 13:10

3

Many predicates define some kind of an acyclic path built from edges defined via a binary relation, quite similarly to defining transitive closure. A generic definition is thus called for. Note tha...
Viable asked 19/5, 2015 at 14:24

1

Solved

In sicstus prolog, there's a predicate: maplist(:Pred, +List) Pred is supposed to take just one argument - List element. How can I pass a 2-argument predicate, with first argument defined? In ot...
Narcotism asked 10/6, 2015 at 14:7

3

In CLP(FD), we frequently need to state: "This is a list of integers and finite domain variables in (sometimes: strictly) ascending/descending order." Is there any CLP(FD) system that provides a g...
Hypogeum asked 18/11, 2014 at 9:26

2

Solved

To calculate the hamming distance between two lists of the same length, I use foldl(hamm, A, B, 0, R). with this definition of hamm/4: hamm(A, A, V, V) :- !. hamm(A, B, V0, V1) :- A \= B, V1 is V0...
Gargantuan asked 20/12, 2012 at 7:11

2

The following higher order predicate succeeds if all pairs of the list's elements are true for a given relation. Is there a common or better, more intention revealing name for this relation? My or...
Worl asked 8/4, 2014 at 23:29

1

Many predicates essentially use some form of transitive closure, only to discover that termination has to be addressed too. Why not solve this once and forever with closure0/3: :- meta_predicate(cl...
Judijudicable asked 15/11, 2014 at 13:4

2

This is the code that i am trying to understand. co(X) :- co(X,[],L). co([],A,A):- write(A). co([X|Xs], A, L) :- p(X-Z,A,R), !, Z1 is Z+1, co(Xs, [X-Z1|R], L). co([X|Xs], A, L) :- co(Xs, [X-1|A],...
Nationality asked 14/11, 2014 at 10:15

2

Solved

So the univ operator. I don't exactly understand it. For example this: foo(PredList,[H|_]) :- bar(PredList,H). foo(PredList,[_|T]) :- foo(PredList,T),!. bar([H|_],Item) :- G =.. [H,Item],G. bar(...
Lice asked 9/11, 2010 at 0:41

1

How do you write a Prolog procedure map(List, PredName, Result) that applies the predicate PredName(Arg, Res) to the elements of List, and returns the result in the list Result? For example: test...
Starve asked 13/7, 2011 at 17:23
1

© 2022 - 2024 — McMap. All rights reserved.