# Higher-order predicates

Author(s): Daniel Cabeza, Manuel Carro.

Version: 1.10#6 (2004/8/7, 21:46:39 CEST)

Version of last change: 1.7#208 (2002/4/23, 19:9:14 CEST)

This library implements a few basic higher-order predicates. These add functionality to the basic higher-order functionality of Ciao. Examples of the latter are: Using pred(1):

```  list(L, functor(_,2))
list(L, >(0))
```

Using pred(2):

## Usage and interface (`hiordlib`)

• Library usage: `:- use_module(library(hiordlib)).`
• Exports:
• Predicates: `map/3`, `foldl/4`, `minimum/3`.

## Documentation on exports (`hiordlib`)

PREDICATE: map/3:

Meta-predicate with arguments: `map(?,pred(2),?)`.

Usage: `map(LList, Op, RList)`

• Description: Examples of use:
```  map([1,3,2], arg(f(a,b,c,d)), [a,c,b]) or
map([1,3,2], nth([a,b,c,d]), [a,c,b])
map(["D","C"], append("."), ["D.","C."])
```

PREDICATE: foldl/4:

Meta-predicate with arguments: `foldl(?,?,pred(3),?)`.

Usage: `foldl(List, Seed, Op, Result)`

• Description: Example of use:
```?- foldl(["daniel","cabeza","gras"], "",
(''(X,Y,Z) :- append(X, " "||Y, Z)), R).

R = "daniel cabeza gras " ?
```

PREDICATE: minimum/3:

Meta-predicate with arguments: `minimum(?,pred(2),?)`.

Usage: `minimum(?List, +SmallerThan, ?Minimum)`

• Description: `Minimum` is the smaller in the nonempty list `List` according to the relation `SmallerThan`: `SmallerThan(X, Y)` succeeds iff X is smaller than Y.
• The following properties should hold at call time: `?List` is a list. (`basic_props:list/1`) `+SmallerThan` is a term which represents a goal, i.e., an atom or a structure. (`basic_props:callable/1`) `?Minimum` is any term. (`basic_props:term/1`)