-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.ae
More file actions
46 lines (35 loc) · 798 Bytes
/
Copy pathinit.ae
File metadata and controls
46 lines (35 loc) · 798 Bytes
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
--
-- $Id: init.ae,v 1.7 2004/07/11 04:53:08 ikh Exp $
--
--
-- Loop neverending ...
-- ( f -> f )
--
0 "loop" def
[ dup @ "loop" lookup @ ] "loop" redefine
--
-- Factorial
-- ( n 1 -> 0 n! )
--
0 "fact" def
[ over * swap 1 swap - swap over [] swap [ "fact" lookup @ ] swap if ] "fact" redefine
0 "fact'" def
[ over * swap 1 swap - swap over >a [] [ "fact'" lookup @ ] a> if ] "fact'" redefine
--
-- squared
--
[ dup * ] "squared" def
--
-- Y combinator !!!
-- Y(f)=f(Y(f))
--
[ [ over over swap @ ] dup @ ] "myY" def
--
-- for
--
[ swap dup . "," s. dec swap over [ drop ] over if ] "for" def
[ >a swap >a @ a> swap >a @ a> a> @ ] "merge" def
0 "dec" def
[ 1 . 1 - dup >a [] [dec] a> if ] "dec" redefine
[ 1 . ] "xxx" def
[ 2 . "xxx" lookup @ ] "xxx" redefine