Merge branch 'master' of git://factorcode.org/git/factor
commit
570315d8c5
|
@ -1,6 +1,16 @@
|
|||
USING: help.markup help.syntax math math.vectors vectors ;
|
||||
IN: math.quaternions
|
||||
|
||||
HELP: q+
|
||||
{ $values { "u" "a quaternion" } { "v" "a quaternion" } { "u+v" "a quaternion" } }
|
||||
{ $description "Add quaternions." }
|
||||
{ $examples { $example "USING: math.quaternions prettyprint ;" "{ C{ 0 1 } 0 } { 0 1 } q+ ." "{ C{ 0 1 } 1 }" } } ;
|
||||
|
||||
HELP: q-
|
||||
{ $values { "u" "a quaternion" } { "v" "a quaternion" } { "u-v" "a quaternion" } }
|
||||
{ $description "Subtract quaternions." }
|
||||
{ $examples { $example "USING: math.quaternions prettyprint ;" "{ C{ 0 1 } 0 } { 0 1 } q- ." "{ C{ 0 1 } -1 }" } } ;
|
||||
|
||||
HELP: q*
|
||||
{ $values { "u" "a quaternion" } { "v" "a quaternion" } { "u*v" "a quaternion" } }
|
||||
{ $description "Multiply quaternions." }
|
||||
|
|
|
@ -24,3 +24,7 @@ math.constants ;
|
|||
[ t ] [ qk q>v v>q qk = ] unit-test
|
||||
[ t ] [ 1 c>q q1 = ] unit-test
|
||||
[ t ] [ C{ 0 1 } c>q qi = ] unit-test
|
||||
[ t ] [ qi qi q+ qi 2 q*n = ] unit-test
|
||||
[ t ] [ qi qi q- q0 = ] unit-test
|
||||
[ t ] [ qi qj q+ qj qi q+ = ] unit-test
|
||||
[ t ] [ qi qj q- qj qi q- -1 q*n = ] unit-test
|
||||
|
|
|
@ -20,6 +20,12 @@ IN: math.quaternions
|
|||
|
||||
PRIVATE>
|
||||
|
||||
: q+ ( u v -- u+v )
|
||||
v+ ;
|
||||
|
||||
: q- ( u v -- u-v )
|
||||
v- ;
|
||||
|
||||
: q* ( u v -- u*v )
|
||||
[ q*a ] [ q*b ] 2bi 2array ;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: accessors ascii assocs biassocs combinators hashtables kernel lists literals math namespaces make multiline openal parser sequences splitting strings synth synth.buffers ;
|
||||
IN: morse
|
||||
|
||||
ERROR: no-morse-code ch ;
|
||||
ERROR: no-morse-ch ch ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
@ -11,7 +11,7 @@ CONSTANT: dot-char CHAR: .
|
|||
CONSTANT: dash-char CHAR: -
|
||||
CONSTANT: char-gap-char CHAR: \s
|
||||
CONSTANT: word-gap-char CHAR: /
|
||||
CONSTANT: unknown-char "?"
|
||||
CONSTANT: unknown-char CHAR: ?
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
@ -76,7 +76,7 @@ CONSTANT: morse-code-table $[
|
|||
]
|
||||
|
||||
: ch>morse ( ch -- morse )
|
||||
ch>lower morse-code-table at unknown-char or ;
|
||||
ch>lower morse-code-table at unknown-char 1string or ;
|
||||
|
||||
: morse>ch ( str -- ch )
|
||||
morse-code-table value-at char-gap-char or ;
|
||||
|
@ -156,7 +156,8 @@ CONSTANT: beep-freq 880
|
|||
{ dot-char [ dot ] }
|
||||
{ dash-char [ dash ] }
|
||||
{ word-gap-char [ intra-char-gap ] }
|
||||
[ drop intra-char-gap ]
|
||||
{ unknown-char [ intra-char-gap ] }
|
||||
[ no-morse-ch ]
|
||||
} case
|
||||
] interleave ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue