Package jason.stdlib

Class nth

All Implemented Interfaces:
InternalAction, Serializable

@Manual(literal=".nth(index,list,term)", hint="gets the nth term of a list", argsHint={"the position of the term (the first term is at position 0)","the list where to get the term from","the term at referred position of the list."}, argsType={"integer","list","term"}, examples={".nth(0,[a,b,c],X): unifies X with a",".nth(2,[a,b,c],X): unifies X with c",".nth(0,[a,b,c],d): false",".nth(0,[a,b,c],a): true",".nth(5,[a,b,c],X): error",".nth(X,[a,b,c,a,e],a): unifies X with 0 (and 3 if it backtracks)"}, seeAlso={"jason.stdlib.concat","jason.stdlib.delete","jason.stdlib.length","jason.stdlib.member","jason.stdlib.sort","jason.stdlib.max","jason.stdlib.min","jason.stdlib.reverse","jason.stdlib.difference","jason.stdlib.intersection","jason.stdlib.union"}) public class nth extends DefaultInternalAction

Internal action: .nth.

Description: gets the nth term of a list.

Parameters:

  • -/+ index (integer): the position of the term (the first term is at position 0)
  • + list (list or string): the list/string where to get the term from.
  • -/+ term (term): the term at position index in the list.

Examples:

  • .nth(0,[a,b,c],X): unifies X with a.
  • .nth(2,[a,b,c],X): unifies X with c.
  • .nth(2,"abc",X): unifies X with c.
  • .nth(0,[a,b,c],d): false.
  • .nth(0,[a,b,c],a): true.
  • .nth(5,[a,b,c],X): error.
  • .nth(X,[a,b,c,a,e],a): unifies X with 0 (and 3 if it backtracks).
See Also: