used Andale Mono, ping me if u think i should use another monospaced font.
/ ALPHABET A
j: _ic "aA"
j
97 65
j+\:!9
(97 98 99 100 101 102 103 104 105
65 66 67 68 69 70 71 72 73)
_ci j+\:!30
("abcdefghijklmnopqrstuvwxyz{|}~"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^")
3 + 125 * 6 % 100
10.5
2 5 # !10
(0 1 2 3 4
5 6 7 8 9)
???
|
/ SPELLING B
sentence:"index =. a.i.'aA'"
"."=sentence
0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0
sentence
"index =. a.i.'aA'"
s:&"."=sentence
s
7 10 12
(0,s) _ sentence
("index ="
". a"
".i"
".'aA'")
|
/ GRAMMAR C
fahrenheit: 50
(fahrenheit - 32) * 5 % 9
10.0
prices: 3 1 4 2
orders: 2 0 2 1
orders * prices
6 0 8 2
+/ orders * prices
16
+\ 1 2 3 4 5
1 3 6 10 15
2 3 * \ 1 2 3 4 5
1 2 3 4 5
2 3 *\: 1 2 3 4 5
(2 4 6 8 10
3 6 9 12 15)
decr:{x-1}
decr -1 0 1 2 3
-2 -1 0 1 2
PARTS OF SPEECH
50 fahrenheit Nouns/Pronouns
+ - * % decr Verbs/Proverbs
/ \ Adverbs
& Conjunction ???
: Verb-to-be
( ) Punctuation
|
/ TABLES Da
prices: 3 1 4 2
orders: 2 0 2 1
prices * orders
6 0 8 2
prices *\: orders
(6 0 6 3
2 0 2 1
8 0 8 4
4 0 4 2)
TO READ A TABLE,
BORDER IT BY ITS
ARGUMENTS:
* | 2 0 2 1
-----------
3 | 6 0 6 3
1 | 2 0 2 1
4 | 8 0 8 4
2 | 4 0 4 2
|
/ TABLES Db
n: 0 1 2 3
n +/: n
(0 1 2 3
1 2 3 4
2 3 4 5
3 4 5 6)
n */: n
(0 0 0 0
0 1 2 3
0 2 4 6
0 3 6 9)
n ^/: n
(1 1 1 1.0
0 1 2 3.0
0 1 4 9.0
0 1 8 27.0)
???
|
/ TABLES Dc
???
+
+
n: !4
n =\: n
(1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1)
n <\: n
(0 1 1 1
0 0 1 1
0 0 0 1
0 0 0 0)
~n >\: n
(1 1 1 1
0 1 1 1
0 0 1 1
0 0 0 1)
|
/ TABLES Dd
text: " i sing of olaf "
text: text,"glad and big"
alph: " abcdefghijklmno"
alph: alph,"pqrstuvwxyz"
alph[!10]=\:text
(1 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0)
2 13 #(#:'&:'alph=\:text)
(7 3 1 0 2 0 2 3 0 3 0 0 2
0 2 2 0 0 0 1 0 0 0 0 0 0)
2 13 # #:'&:'alph=\:text / freq of alph in text
(7 3 1 0 2 0 2 3 0 3 0 0 2
0 2 2 0 0 0 1 0 0 0 0 0 0)
/ 7 spaces alph[0]
/ 3 a alph[1]
/ 1 b alph[1]
|
/ CLASSIFICATION Ea
x: 1 2 3 4 5 6 7
y: (x-3) * (x-5)
y
8 3 0 -1 0 3 8
range: |n+!(1+|/y-n:&/y)
range
8 7 6 5 4 3 2 1 0 -1
bc: range <\: y
bc
(0 0 0 0 0 0 0
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 0 0 0 0 0 1
1 1 0 0 0 1 1
1 1 0 0 0 1 1
1 1 0 0 0 1 1
1 1 1 0 1 1 1)
|
/ CLASSIFICATION Eb
x: 1 2 3 4 5 6 7
y: (x-3) * (x-5)
y
8 3 0 -1 0 3 8
range: |n+!(1+|/y-n:&/y)
range
8 7 6 5 4 3 2 1 0 -1
|
/
|
/
|
/ CLASSIFICATION +,* on subsets Ee
a: 0 0 0 0 1 1 1 1
b: 0 0 1 1 0 0 1 1
c: 0 1 0 1 0 1 0 1
cct:(a;b;c)
cct
(0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1)
+/cct * 2 3 5
0 5 3 8 2 7 5 10
+/+2 3 5 */:+cct
0 5 3 8 2 7 5 10
*/cct * 2 3 5
0 0 0 0 0 0 0 30
|
g:"23456789"
(!(-2)+#g) !\:g
("23456789"
"34567892"
"45678923"
"56789234"
"67892345"
"78923456")
|
/ last element
/ fast , slow
v: 1000000 _draw 56
#v
1000000
/ get last element
\t do[100;v -1+#v]
0
\t do[100;*|v]
5618
|
n&/:n
(0 0 0 0
0 1 1 1
0 1 2 2
0 1 2 3)
|
/ alternate takes of 1s and 0s
4#1 0
1 0 1 0
1#1 0
,1
5#1 0
1 0 1 0 1
5#0 1
0 1 0 1 0
|
/ split string by spaces
str:"this is a test."
" "=str
0 0 0 0 1 0 0 1 0 1 0 0 0 0 0
g:&" "=str
g
4 7 9
g:0,g
g
0 4 7 9
g _ str
("this"
" is"
" a"
" test.")
|
/ reverse
r:"reverse"
s:`$r
s
`reverse
t:2#s
t
`reverse `reverse
|:'$t
("esrever"
"esrever")
`$|:'$t
`esrever `esrever
|
/ ascii of number
,/$2 _vs 15
"1111"
,/$2 _vs 15345
"11101111110001"
|
/ freq of values
l: 10000 _draw 5
l[*:'p],'#:'p:=l
(4 1972
0 1945
3 2029
1 2013
2 2041)
g[<g:l[*:'p],'#:'p:=l]
(0 1945
1 2013
2 2041
3 2029
4 1972)
|
/ wrong terminology(?)
/ flip matrix
n:!4
m:n|/:n
m
(0 1 2 3
1 1 2 3
2 2 2 3
3 3 3 3)
||:'m
(3 3 3 3
3 2 2 2
3 2 1 1
3 2 1 0)
|:'|m
(3 3 3 3
3 2 2 2
3 2 1 1
3 2 1 0)
|
/ alpha
_ci 97+!26
"abcdefghijklmnopqrstuvwxyz"
|
2 # !3
0 1
2 #/: !3
(0 0
1 1
2 2)
2 #/ !3
2
2 #\ !3
(2
0 0
()
2)
2 #:\ !3
(0 1 2
3
1)
|
/ matrix indexing
g:(4 _draw -4)+/:!4
g
(2 0 3 1
3 1 4 2
4 2 5 3
5 3 6 4)
g[0;]
2 0 3 1
g[;1]
0 1 2 3
g[;1 3]
(0 1
1 2
2 3
3 4)
g[1 3;]
(3 1 4 2
5 3 6 4)
|
/ identity matrix
n:!4
n~'/:n
(1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1)
|
/ searching vectors
v:10000 _draw -10000
\t do[10000;999 _in v]
630
/ using _bin is faster
/ even for small vectors
\t do[10000;v _bin 999]
10
|
/ string to symbol
s:"applegate"
`$($:'s)
`a `p `p `l `e `g `a `t `e
/ try take
4 2#s
("ap"
"pl"
"eg"
"at")
`$(4 2#s)
`ap `pl `eg `at
`$2 4#s
`appl `egat
|
/ _dot
/ x _dot y ~ +/x*y
/ arthur says ~2001
/ +/x*y has 3 loads and 1 store per element
/ x _dot y has 2 loads
/ NB: for +/x*y , +/ is not sum
g:2 2 _draw 5
g
(1 4
3 4)
+g
(1 3
4 4)
|
/ sum > 2gb
s1
{+/0.0$$x}
s1[50#*/(30#2)]
53687091200.0
|
/ MFTL 13C
/ k
s:"do you love me"
|/s=/:"aeiou"
0 1 0 0 1 1 0 0 1 0 1 0 0 1
s[&|/s=/:"aeiou"]
"oouoee"
s[&~|/s=/:"aeiou"]
"d y lv m"
/ j
or/'aeiou' =/ s
0 1 0 0 1 1 0 0 1 0 1 0 0 1
|
/ rotate until
/ last 2 numbers
g:"23456789"
(!(-2)+#g) !\:g
("23456789"
"34567892"
"45678923"
"56789234"
"67892345"
"78923456")
/ 4 take chars of each string
4#'(!(-2)+#g)
("2345"
"3456"
"4567"
"5678"
"6789"
"7892")
/ form string to float
/ see last value in vector
0.0$4#'(!(-2)+#g) !\:g
2345 3456 4567 5678 6789 7892.0
|
/ experiment
4#/:g
("2222"
"3333"
"4444"
"5555"
"6666"
"7777"
"8888"
"9999")
2 3 _ g
(,"3"
"456789")
|
/ forward reduction
(!#g) _\: g
("123456789"
"23456789"
"3456789"
"456789"
"56789"
"6789"
"789"
"89"
,"9")
|
/
|
/
|
/
|