Play

Check-in [a22d52bc99]
Login
Overview
Comment:Added booleans to stdlib.
Timelines: family | ancestors | descendants | both | stdlib
Files: files | file ages | folders
SHA3-256: a22d52bc994e9ba411d93e5cf694a9feb486ee99bf8cd5ede1470b40593a8ffd
User & Date: robin.hansen on 2021-04-08 14:02:42
Other Links: branch diff | manifest | tags
Context
2021-04-08
14:08
Add helper function to perform two quotations on a single value. check-in: fd3d3efaf8 user: robin.hansen tags: stdlib
14:02
Added booleans to stdlib. check-in: a22d52bc99 user: robin.hansen tags: stdlib
13:42
Rename stdlib/basic to stdlib/core. check-in: e4c78a4a49 user: robin.hansen tags: stdlib
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified stdlib/src/core.play from [4976a8ad2e] to [500707602c].


















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

















defmulti: zero?
type: Int -- Int
: Int( value 0 )
  drop 1
: Int











  drop 0

defmulti: select
type: Int a a -- a
: Int( value 0 )
  rotate drop drop
: Int
  drop swap drop



def: if
type: a... Int [ a... -- b... ] [ a... -- b... ] -- b...
: select !



def: over
type: a b -- a b a
: swap dup rotate

def: drop2
type: a b c -- a
: drop drop
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|

|

>
>
>
>
>
>
>
>
>
>
>
|


|
<
<
|

>
>


|

>
>








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
31
32
33
34
35
36
37


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Everything in core is imported into every module outside the standard library

def: test
: 5 6
  int= not
  [ 10 ]
  [ 20 ] if

# booleans

defunion: Bool
: True
: False

defstruct: True
defstruct: False

defmulti: zero?
type: Int -- Bool
: Int( value 0 )
  drop True
: Int
  drop False 

def: int=
type: Int Int -- Bool
: - zero?

defmulti: not
type: Bool -- Bool
: True
  drop False
: False
  drop True

defmulti: select
type: Bool a a -- a


: True
  drop swap drop
: False
  rotate drop2

def: if
type: a... Bool [ a... -- b... ] [ a... -- b... ] -- b...
: select !

# stack manipulation

def: over
type: a b -- a b a
: swap dup rotate

def: drop2
type: a b c -- a
: drop drop