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

Factor

  1. IN: scratchpad 20 9 * 5.0 / 32 + .
  2. Booleans:t/f
  3. Sequences:{ { "one" 1 } { "two" 2 } { "three" 3 } { "four" 4 } } //注意空格
  4. Quotations(匿名函数):[ 42 + ]
    1. call
  5. 条件语句
    1. IN: scratchpad 10 0 > [ "pos" ] [ "neg" ] if .
    2. 或 IN: scratchpad 10 0 > "pos" "neg" ? .
  6. Stack Shuffling
    1. dup, drop, nip, swap, over, rot, pick
  7. Higher-Order Words with Combinators
    1. IN: scratchpad 44.50 [ 0.05 * ] [ 0.09975 * ] bi //见鬼
      1. bi*
      2. bi@
      3. tri tri* tri@
  8. Vocabularies
    1. IN: scratchpad USE: present
    2. IN: scratchpad SYMBOL: tax-rate //What the Fuck!
    3.  : greeting ( name -- greeting ) "Hello, " swap append ; //定义一个库函数?IN: examples.greeter
    4.  : hello-world ( -- ) "world" greeting print ; //USE: examples.greeter
  9. Tuples
    1. TUPLE: cart-item name price quantity ; //?类型没有声明
      1. price>>(读)
      2. >>price(写)
      3. change-price
    2. "Seven Languages Book" 25.00 1 cart-item boa //By Order of Arguments
  10. 标准库(字典):略
  11. IN: scratchpad "demos" run

你可能感兴趣的:(word,factor,Vocabularies,Quotations,Combinators)