Package jason.stdlib

Class sublist

All Implemented Interfaces:
InternalAction, Serializable

@Manual(literal=".sublist(sublist,list)", hint="checks if a list is a subset of a given list, backtracking all free variables", argsHint={"the sublist to be checked","the list where the sublist may be to be a subset"}, argsType={"list","list"}, examples={".sublist([a],[a,b,c]): true",".sublist([b],[a,b,c]): true",".sublist([c],[a,b,c]): true",".sublist([a,b],[a,b,c]): true",".sublist([b,c],[a,b,c]): true",".sublist([d],[a,b,c]): false",".sublist(X,[a,b,c]): unifies X with any sublist of the list, i.e., [a,b,c], [a,b], [a], [b,c], [b], [c], and [] in this order"}, seeAlso={"jason.stdlib.concat","jason.stdlib.delete","jason.stdlib.length","jason.stdlib.member","jason.stdlib.sort","jason.stdlib.shuffle","jason.stdlib.substring","jason.stdlib.nth","jason.stdlib.max","jason.stdlib.min","jason.stdlib.reverse","jason.stdlib.difference","jason.stdlib.intersection","jason.stdlib.union"}) public class sublist extends DefaultInternalAction

Internal action: .sublist(S,L).

Description: checks if some list S is a sublist of list L. If S has free variables, this internal action backtracks all possible values for S. This is based on .prefix and .suffix (try prefixes first then prefixes of each suffix).

Parameters:

  • +/- sublist (list): the sublist to be checked.
  • + list (list): the list where the sublist is from.

Examples:

  • .sublist([a],[a,b,c]): true.
  • .sublist([b],[a,b,c]): true.
  • .sublist([c],[a,b,c]): true.
  • .sublist([a,b],[a,b,c]): true.
  • .sublist([b,c],[a,b,c]): true.
  • .sublist([d],[a,b,c]): false.
  • .sublist([a,c],[a,b,c]): false.
  • .sublist(X,[a,b,c]): unifies X with any sublist of the list, i.e., [a,b,c], [a,b], [a], [b,c], [b], [c], and [] in this order; note that this is not the order in which its usual implementation would return in logic programming (see note on .prefix).
See Also: