モジュール lillib:lists

This module provides various predicates for manipulating lists, such as append and reverse.

バージョン

April 07, 1999

登場したバージョン

July 09, 1998

著者


目次

述語


Top of this page Contents Index of this package LiLFeS Documents LiLFeS Home Page Tsujii laboratory

述語

append/3

書式append(?$L1, ?$L2, ?$L3)
引数
?$L1list List 1
?$L2list List 2
?$L3list Concatenation of List 1 and List 2
This is true when $L3 is the combined list of the elements in $L1 and $L2 in the original orders.
 > ?- append([1, 2, 3], [4, 5], X).
  X: < 1, 2, 3, 4, 5 >

revappend/3

書式revappend(?$L1, ?$L2, ?$L3)
引数
?$L1list Reversed list
?$L2list List
?$L3list Concatenation
This is true when $L3 is the combined list of the elements in $L1 and $L2, in the reversed order as to $L1 and in the original order as to $L2.
 > ?- revappend([1, 2, 3], [4, 5], X).
  X: < 3, 2, 1, 4, 5 >

append_list/2

書式append_list(+$LL, -$L)
引数
+$LLlist of list Input lists
-$Llist Concatenation of the lists
This lets $L3 be the combined list of the elements in the elements in $LL.
 > ?- append_list([[1, 2], [3], [4, 5]],X).
  X: < 1, 2, 3, 4, 5 >

delete/3

書式delete(+$List1, +$Elem, -$List2)
引数
+$List1list input list
+$Elembot an element to be removed
-$List2list output
This removes elements $Elem from $List and returns to $List2.
 > ?- delete([1, 2, 2, 4, 5], 2, X).
  X: < 1, 4, 5 >

reverse/2

書式reverse(?$L1, ?$L2)
引数
?$L1list Original ordered list
?$L2list Reversed ordered list
This is true when $L1 and $L2 have the same elements but in reversed orders each other.
 > ?- reverse([1, 2, 3, 4], X).
  X: < 4, 3, 2, 1 >

last/2

書式last(?$L, ?$X)
引数
?$Llist Input list
?$Xbot The last element of the list
This lets $X be the last element in $L.
 > ?- last([1, 2, 3, 4], X).
  X: 4

member/2

書式member(?$X, +$L)
引数
?$Xbot a list element
+$Llist a list
This is true when $X is unified with an element in $L.
 > ?- member(X, [1, 2, 3]).
  X: 1
  Enter ';' for more choices, otherwise press ENTER --> ;
  X: 2
  Enter ';' for more choices, otherwise press ENTER --> ;
  X: 3
  Enter ';' for more choices, otherwise press ENTER --> ;
  no

member_e/2

書式member_e(?$X, +$L)
引数
?$Xbot a list element
+$Llist a list
関連項目member/2
This is true when $X is equivalent to an element in $L.

member_i/2

書式member_i(?$X, +$L)
引数
?$Xbot a list element
+$Llist a list
関連項目member/2
This is true when $X is identical to an element in $L.

member_s/2

書式member_s(?$X, +$L)
引数
?$Xbot a list element
+$Llist a list
関連項目member/2
This is true when $X subsumes an element in $L.

member_sd/2

書式member_sd(?$X, +$L)
引数
?$Xbot a list element
+$Llist a list
関連項目member/2
This is true when $X is subsumed by an element in $L.

memberchk/2

書式memberchk(+$X, +$L)
引数
+$Xbot a list element
+$Llist a list
関連項目member/2
This is true when $X is unified with an element in $L. This does not succeeds more than once.
 > ?- memberchk(X, [1, 2, 3, 4]).
  X: 1

memberchk_e/2

書式memberchk_e(+$X, +$L)
引数
+$Xbot a list element
+$Llist a list
関連項目memberchk/2
This is true when $X is equivalent to an element in $L. This does not succeeds more than once.

memberchk_i/2

書式memberchk_i(+$X, +$L)
引数
+$Xbot a list element
+$Llist a list
関連項目memberchk/2
This is true when $X is identical to an element in $L. This does not succeed more than once.

memberchk_s/2

書式memberchk_s(+$X, +$L)
引数
+$Xbot a list element
+$Llist a list
関連項目memberchk/2
This is true when $X subsume an element in $L. This does not succeed more than once.

memberchk_sd/2

書式memberchk_sd(+$X, +$L)
引数
+$Xbot a list element
+$Llist a list
関連項目memberchk/2
This is true when $X is subsumed by an element in $L. This does not succeed more than once.

member_2/4

書式member_2(?$X1, +$L1, ?$X2, +$L2)
引数
?$X1bot a list element
+$L1list a list
?$X2bot a list element
+$L2list a list
関連項目member/2
This is true when $X1 and $X2 are unified with an element in $L1 and $L2 respectively. Where $X1 and $X2 are from the heads of $L1 and $L2 must be the same.
 > ?- member_2(X, [1, 2], Y, [4, 5]).
  X: 1
  Y: 4
  Enter ';' for more choices, otherwise press ENTER --> ;
  X: 2
  Y: 5
  Enter ';' for more choices, otherwise press ENTER --> ;
  no

fast_member/2

書式fast_member(+$L, ?$X)
引数
+$Llist a list
?$Xbot a list element
関連項目member/2
This is true when $X is unified with an element in $L. This is the same as 'member', but the order of the arguments is changed and this is faster.
 > ?- fast_member([1, 2, 3], X).
  X: 1
  Enter ';' for more choices, otherwise press ENTER --> ;
  X: 2
  Enter ';' for more choices, otherwise press ENTER --> ;
  X: 3
  Enter ';' for more choices, otherwise press ENTER --> ;
  no

fast_member_2/4

書式fast_member_2(+$L1, ?$X1, +$L2, ?$X2)
引数
+$L1list list
?$X1bot list element
+$L2list list
?$X2bot list element
関連項目member_2/4 fast_member/2
This is true when $X1 and $X2 are unified with elements in $L1 and $L2 respectively. Where $X1 and $X2 are from the heads of $L1 and $L2 must be the same. This is the same as 'member_2', but the order of the arguments is changed and this is faster.
 > ?- fast_member_2([1, 2], X, [3, 4], Y).
  X: 1
  Y: 3
  Enter ';' for more choices, otherwise press ENTER --> ;
  X: 2
  Y: 4
  Enter ';' for more choices, otherwise press ENTER --> ;
  no

assoc/3

書式assoc(+$X, +$L, -$Y)
引数
+$Xbot key
+$Llist of ',/2' association list
-$Ybot data
This lets $Y be the second element of the pair whose first element is unified with $X. The 2-element pair (',/2') is the first proper one in $L. This does not succeed more than once.
 > ?- assoc(1, [(1, "a"), (2, "b")], X).
  X: "a"

assoc_e/3

書式assoc_e(+$X, +$L, -$Y)
引数
+$Xbot key
+$Llist of ',/2' association list
-$Ybot data
関連項目assoc/3
This lets $Y be the second element of the pair whose first element is equivalent to $X. The 2-element pair (',/2') is the first proper one in $L. This does not succeed more than once.

assoc_i/3

書式assoc_i(+$X, +$L, -$Y)
引数
+$Xbot key
+$Llist of ',/2' association list
-$Ybot data
関連項目assoc/3
This lets $Y be the second element of the pair whose first element is identical to $X. The 2-element pair (',/2') is the first proper one in $L. This does not succeed more than once.

remove_duplicates/2

書式remove_duplicates(+$L1, -$L2)
引数
+$L1list an original list
-$L2list output list
This lets $L2 be the result of removing all equivalent duplicate elements in $L1.
 > ?- remove_duplicates([1, 2, 3, 2, 4], X).
  X: < 1, 3, 2, 4 >

listcommon/3

書式listcommon(+$L1, +$L2, -$L3)
引数
+$L1list list 1
+$L2list list 2
-$L3list common part of the lists
著者NISHIDA Kenji (nishiken@is.s.u-tokyo.ac.jp)
This lets $L3 be a list of all the elements that have equivalent elements both in $L1 and in $L2.
 > ?- listcommon([1, 2, 3, 4], [5, 4, 3], X).
  X: < 3, 4 >

flatten_list/2

書式flatten_list(+$L1, -$L2)
引数
+$L1list input list
-$L2list output list
This lets $L2 be a flattened list of $L1.
 > ?- flatten_list([1, [2, [3, 4], 5]], X).
  X: < 1, 2, 3, 4, 5 >

make_n_list/3

書式make_n_list(+$N, +$X, -$L)
引数
+$Ninteger (>= 0) length of a list
+$Xbot a list element
-$Llist output
This lets $L be a list whose length is $N and all the elements are equivalent to $X.
 > ?- make_n_list(5, "hoge", X).
  X: < "hoge", "hoge", "hoge", "hoge", "hoge" >

make_num_list/3

書式make_num_list(+$FROM, +$BEFORE, -$RESULT)
引数
+$FROMinteger a start of a list
+$BEFOREinteger an end of the list
-$RESULTlist of integers output
This lets $RESULT be a list whose elements are the integers from $FROM before $BEFORE.
 > ?- make_num_list(2, 5, X).
  X: < 2, 3, 4 >

length/2

書式length(+$L, -$N)
引数
+$Llist input list
-$Ninteger length of the list
This lets $N be the length of $L.
 > ?- length([3, 3, 3, 3], X).
  X: 4

nth_elem/3

書式nth_elem(+$LIST, +$N, -$ELEM)
引数
+$LISTlist a list
+$Ninteger index
-$ELEMbot an element of the list
This returns $Nth element of the list $LIST as $ELEM.
 > ?- nth([2, 4, 6, 8], 2, X).
  X: 6

set_difference/3

書式set_difference(+$Set1, +$Set2, -$Diff)
引数
+$Set1list Set 1
+$Set2list Set 2
This returns the elements of $Set1 not included in $Set2.
 > ?- set_difference([1, 2, 3, 4], [6, 4, 2], X).
  X: < 1, 3 >

set_difference_e/3

書式set_difference_e(+$Set1, +$Set2, -$Diff)
引数
+$Set1list Set 1
+$Set2list Set 2
関連項目set_difference/3
This returns the elements of $Set1 not included in $Set2.

set_difference_i/3

書式set_difference_i(+$Set1, +$Set2, -$Diff)
引数
+$Set1list Set 1
+$Set2list Set 2
関連項目set_difference/3
This returns the elements of $Set1 not included in $Set2.

input_list/2

書式input_list(+$STRING, -$LIST)
引数
+$STRINGstring Lisp 形式のリスト
-$LISTlist LiLFeS 形式のリスト
関連項目output_list/2
Lisp 形式のリストを LiLFeS 形式のリストへ変換する.

output_list/2

書式output_list(+$LIST, -$STRING)
引数
+$LISTlist LiLFeS 形式のリスト
-$STRINGstring Lisp 形式のリスト
関連項目lisp_to_lilfes/2
LiLFeS 形式のリストを Lisp 形式のリストに変換する.

dlength/3

書式dlength(+Head, +Tail, -N)
引数
+Headlist
+Taillist
-Ninteger
Returns the length of the difference list between Head and Tail.

dmember/3

書式dmember(+LHead, +LTail, ?E)
引数
+LHeadhead of the difference list
+LTailtail (end) of the difference list
?Ethe element to search for
as with member, but searches in a difference list given by 'LHead' and 'LTail'

dmember_2/5

書式dmember_2(+L1Head, +L1Tail, ?E1, +L2, ?E2)
引数
+L1Headhead of the first list (difference list)
+L1Tailtail (end) of the first list
?E1the element to search for in the first list
+L2second list
?E2the element to search for in the second list
as 'fast_member_2', but the first list is considered a difference list It is not necessary to give the 2nd list as difference list as well, as both lists are processed in tandem.

Top of this page Contents Index of this package LiLFeS Documents LiLFeS Home Page Tsujii laboratory

コメントはこちら:
MITSUISHI Yutaka (mitsuisi@is.s.u-tokyo.ac.jp)

This document is automatically created by lildoc on Fri Sep 24 14:14:00 2004