Skip to main content
Last updated

List operators

at

pact
(at k l)
pact
(at k l)
• takes k: string
• takes l: [a]
• produces a
pact
(at i l)
pact
(at i l)
• takes i: integer
• takes o: list
• produces bool

projection

Supported in either invariants or properties.

length

pact
(length s)
pact
(length s)
• takes s: [a]
• produces integer

List length

Supported in either invariants or properties.

contains

pact
(contains x xs)
pact
(contains x xs)
• takes x: a
• takes xs: [a]
• produces bool
pact
(contains k o)
pact
(contains k o)
• takes k: string
• takes o: object
• produces bool
pact
(contains value string)
pact
(contains value string)
• takes value: string
• takes string: string
• produces bool

List / string / object contains

Supported in either invariants or properties.

enumerate

pact
(enumerate from to step)
pact
(enumerate from to step)
• takes from: integer
• takes to: integer
• takes step: integer
• produces [integer]

Returns a sequence of numbers as a list

Supported in either invariants or properties.

reverse

pact
(reverse xs)
pact
(reverse xs)
• takes xs: [a]
• produces [a]

reverse a list of values

Supported in either invariants or properties.

sort

pact
(sort xs)
pact
(sort xs)
• takes xs: [a]
• produces [a]

sort a list of values

Supported in either invariants or properties.

drop

pact
(drop n xs)
pact
(drop n xs)
• takes n: integer
• takes xs: [a]
• produces [a]

drop the first n values from the beginning of a list (or the end if n is negative)

Supported in either invariants or properties.

take

pact
(take n xs)
pact
(take n xs)
• takes n: integer
• takes xs: [a]
• produces [a]

take the first n values from xs (taken from the end if n is negative)

Supported in either invariants or properties.

make-list

pact
(make-list n a)
pact
(make-list n a)
• takes n: integer
• takes a: a
• produces [a]

create a new list with n copies of a

Supported in either invariants or properties.

map

pact
(map f as)
pact
(map f as)
• takes f: a -> b
• takes as: [a]
• produces [b]

apply f to each element in a list

Supported in either invariants or properties.

filter

pact
(filter f as)
pact
(filter f as)
• takes f: a -> bool
• takes as: [a]
• produces [a]

filter a list by keeping the values for which f returns true

Supported in either invariants or properties.

distinct

pact
(distinct xs)
pact
(distinct xs)
• takes xs: [a]
• produces [a]

returns a list of distinct values

Supported in either invariants or properties.

fold

pact
(fold f a bs)
pact
(fold f a bs)
• takes f: a -> b -> a
• takes a: a
• takes bs: [b]
• produces a

reduce a list by applying f to each element and the previous result

Supported in either invariants or properties.

hash

pact
(hash xs)
pact
(hash xs)
• takes xs: [a]
• produces string
• where a is of type integer, decimal, bool, or string

BLAKE2b 256-bit hash of lists

Supported in properties only.

Was this page helpful?