最后活跃于 16 hours ago

point.gilded 原始文件 Playground
1: sq dup * ;
2
3: keep
4 over { call } dip ;
5
6: mag@ 'mag@ print
7 'x @ dup print sq
8 'y @ dup print sq
9 + sqrt ;
10
11: move@
12 'y @ + 'y =@
13 'x @ + 'x =@ ;
14
15: :mag
16 'mag swap call ;
17
18: :move
19 'move swap call ;
20
21: {point-methods} {
22 { dup 'get = } { pop @ }
23 { dup 'set = } { pop =@ }
24 { dup 'mag = } { pop mag@ }
25 { dup 'move = } { pop move@ }
26} ;
27
28: [point]
29 {point-methods} [ 'methods @ cond ] {
30 'x 'y 'methods
31 } bind ;
32
3310 20 [point] 'position =@
34
35-7 -16 'position @ { :move } keep :mag