Play

Check-in [744a763bab]
Login
Overview
Comment:Added List data structure. The implementation of fold revealed several bugs in the compiler.
Timelines: family | ancestors | descendants | both | stdlib
Files: files | file ages | folders
SHA3-256: 744a763bab36aa0ff17486ebeb9938889c24976f4efa4281c7f553f7fd7d86b9
User & Date: robin.hansen on 2021-04-09 08:08:08
Other Links: branch diff | manifest | tags
Context
2021-04-10
09:26
Remove optimization which caused a crash if a quotation referenced a yet-to-be qualified word. check-in: 49cc39c5d1 user: robin.hansen tags: stdlib
2021-04-09
08:08
Added List data structure. The implementation of fold revealed several bugs in the compiler. check-in: 744a763bab user: robin.hansen tags: stdlib
07:37
Added Pair/2-Tuple data structure. check-in: a327035cc3 user: robin.hansen tags: stdlib
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified stdlib/play.json from [8dbe1d2071] to [f2261f0ba9].

1
2
3
4
5
6
7
8

9
10
11
12
{
    "name": "play/standard_library",
    "version": "0.2.0",
    "language-version": "0.2.0",
    "exposed-modules": [
        "core",
        "maybe",
        "pair"

    ],
    "dependencies": {},
    "package-paths": []
}







|
>




1
2
3
4
5
6
7
8
9
10
11
12
13
{
    "name": "play/standard_library",
    "version": "0.2.0",
    "language-version": "0.2.0",
    "exposed-modules": [
        "core",
        "maybe",
        "pair",
        "list"
    ],
    "dependencies": {},
    "package-paths": []
}

Added stdlib/src/list.play version [4f0302ab53].





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
30
defunion: List a
: NonEmpty a
: Empty

defstruct: NonEmpty a
: first a
: rest (List a)

defstruct: Empty

defmulti: fold
type: (List a) b [ a b -- b ] -- b
: Empty
  drop swap drop
: NonEmpty
  pair/>Pair
  swap # (Pair b quot) (NonEmpty a)
  [ first> ] [ rest> ] core/split # Pair first rest
  rotate swap # rest first Pair
  pair/spill # rest first b quot
  dup rotate # rest quot first b quot
  ! # rest quot b
  swap # rest b quot
  fold

def: test
: 1 2 3 Empty >NonEmpty >NonEmpty >NonEmpty
  0 [ + ] fold