您的位置:首页 > 其它

Seven More Languages in Seven Weeks (读书笔记):Factor

2016-03-30 15:14 375 查看

Factor

IN: scratchpad 20 9 * 5.0 / 32 + .
Booleans:t/f
Sequences:{ { "one" 1 } { "two" 2 } { "three" 3 } { "four" 4 } } //注意空格
Quotations(匿名函数):[ 42 + ]
call

条件语句
IN: scratchpad 10 0 > [ "pos" ] [ "neg" ] if .
或 IN: scratchpad 10 0 > "pos" "neg" ? .

Stack Shuffling
dup, drop, nip, swap, over, rot, pick

Higher-Order Words with Combinators
IN: scratchpad 44.50 [ 0.05 * ] [ 0.09975 * ] bi //见鬼
bi*
bi@
tri tri* tri@

Vocabularies
IN: scratchpad USE: present
IN: scratchpad SYMBOL: tax-rate //What the Fuck!
 : greeting ( name -- greeting ) "Hello, " swap append ; //定义一个库函数?IN: examples.greeter
 : hello-world ( -- ) "world" greeting print ; //USE: examples.greeter

Tuples
TUPLE: cart-item name price quantity ; //?类型没有声明
price>>(读)
>>price(写)
change-price

"Seven Languages Book" 25.00 1 cart-item boa //By Order of Arguments

标准库(字典):略
IN: scratchpad "demos" run
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息