root/trunk/orca/rebol_compat.r

Revision 9, 1.9 kB (checked in by krobillard, 3 years ago)

Added rebol_compat.r again.

Line 
1 ; REBOL compatibility functions
2 ;
3 ; Enable rebol in config.r to include these.
4
5
6 add:        func [a [number!] b [number!]] [a + b]
7 subtract:   func [a [number!] b [number!]] [a - b]
8 divide:     func [a [number!] b [number!]] [a / b]
9 multiply:   func [a [number!] b [number!]] [a * b]
10 zero?:      func [value] [0 = value]
11 negative?:  func [value [number!]] [value < 0]
12 positive?:  func [value [number!]] [value > 0]
13 not-equal?: func [v1 v2] [not :v1 = :v2]
14
15 any-function?: func [tst] [
16     any [
17         function? :tst
18         native? :tst
19         op? :tst
20     ]
21 ]
22
23 array: func [
24     size [number! block!]
25     /initial init
26     /local init2 s
27 ][
28     size: insert copy [] size
29     while [not head? size] [
30         size: back size
31         s: first size
32         s: to-integer s
33         if series? init [init: copy init]
34         init2: init
35         init: copy []
36         loop s [
37             append/only init init2
38         ]
39     ]
40     init
41 ]
42
43 help: ?: func [
44     "Help Function"
45     'word [word!] "What do you need help for"
46     /local fun descr start
47 ][
48     if not value? word [
49         print [word "has no value"]
50         exit
51     ]
52     if any-function? get/any word [
53         fun: get word
54         foreach w second load mold :fun [
55             if string? :w [descr: w]
56             if any-word? :w [break]
57         ]
58         either descr [
59             print descr
60         ][
61             print "(not documented)"
62         ]
63         prin "ARGS:"
64         foreach w second load mold :fun [
65             either refinement? :w [
66                 print ""
67                 print ""
68                 prin [" " w]
69                 start: yes
70             ] [
71             if any-word? :w [
72                 print ""
73                 prin ["    " w "^-"]
74                 start: yes
75             ]]
76             if all [string? :w start] [
77                 prin w
78             ]
79         ]
80         print ""
81         if not start [
82             print "    NO ARGS"
83         ]
84     ]
85     exit
86 ]
87
88
89 ;eof
Note: See TracBrowser for help on using the browser.