File: insert_prime.doc

package info (click to toggle)
hol-light 20190729-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 42,676 kB
  • sloc: ml: 637,078; cpp: 439; makefile: 301; lisp: 286; java: 279; sh: 239; yacc: 108; perl: 78; ansic: 57; sed: 39; python: 13
file content (29 lines) | stat: -rw-r--r-- 772 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
\DOC insert'

\TYPE {insert' : ('a -> 'a -> bool) -> 'a -> 'a list -> 'a list}

\SYNOPSIS
Insert element into list unless it contains an equivalent one already.

\DESCRIBE
If {r} is a binary relation, {x} an element and {l} a list, the call
{insert' r x l} will add {x} to the head of the list, unless the list already 
contains an element {x'} with {r x x'}; if it does, the list is returned 
unchanged. The function {insert} is the special case where {r} is equality.

\FAILURE
Fails only if the relation fails.

\EXAMPLE
{
  # insert' (fun x y -> abs(x) = abs(y)) (-1) [1;2;3];;
  val it : int list = [1; 2; 3]
  
  # insert' (fun x y -> abs(x) = abs(y)) (-1) [2;3;4];;
  val it : int list = [-1; 2; 3; 4]
}

\SEEALSO
insert, mem', subtract', union', unions'.

\ENDDOC