summaryrefslogtreecommitdiff
path: root/prolog/problems/lists/memb_2
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/problems/lists/memb_2')
-rw-r--r--prolog/problems/lists/memb_2/common.py11
-rw-r--r--prolog/problems/lists/memb_2/en.py16
2 files changed, 27 insertions, 0 deletions
diff --git a/prolog/problems/lists/memb_2/common.py b/prolog/problems/lists/memb_2/common.py
new file mode 100644
index 0000000..32d9125
--- /dev/null
+++ b/prolog/problems/lists/memb_2/common.py
@@ -0,0 +1,11 @@
+id = 103
+group = 'lists'
+number = 10
+visible = True
+facts = None
+
+solution = '''\
+memb(X, [X|_]).
+memb(X, [_|T]) :-
+ memb(X, T).
+'''
diff --git a/prolog/problems/lists/memb_2/en.py b/prolog/problems/lists/memb_2/en.py
new file mode 100644
index 0000000..fca82b7
--- /dev/null
+++ b/prolog/problems/lists/memb_2/en.py
@@ -0,0 +1,16 @@
+id = 103
+name = 'memb/2'
+slug = 'find elements in list'
+
+description = '''\
+<p><code>memb(M, L)</code>: <code>M</code> is an element of list <code>L</code>.</p>
+<pre>
+ ?- memb(X, [1,2,3]).
+ X = 1 ;
+ X = 2 ;
+ X = 3.
+ ?- memb(1, [3,2,X]).
+ X = 1.
+</pre>'''
+
+hint = {}