File: shareout.doc

package info (click to toggle)
hol-light 20230128-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 45,636 kB
  • sloc: ml: 688,681; cpp: 439; makefile: 302; lisp: 286; java: 279; sh: 251; yacc: 108; perl: 78; ansic: 57; sed: 39; python: 13
file content (27 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (3)
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
\DOC shareout

\TYPE {shareout : 'a list list -> 'b list -> 'b list list}

\SYNOPSIS
Shares out the elements of the second list according to pattern in first.

\DESCRIBE
The call {shareout pat l} shares out the elements of {l} into the same groups
as the pattern list {pat}, while keeping them in the same order. If there are
more elements in {l} than needed, they will be discarded, but if there are
fewer, failure will occur.

\FAILURE
Fails if there are too few elements in the second list.

\EXAMPLE
{
  # shareout [[1;2;3]; [4;5]; [6]; [7;8;9]] (explode "abcdefghijklmnopq");;
  val it : string list list =
    [["a"; "b"; "c"]; ["d"; "e"]; ["f"]; ["g"; "h"; "i"]]
}

\SEEALSO
chop_list.

\ENDDOC