Using literals vocab for defining computed constants

db4
Alex Chapman 2009-04-20 14:15:38 +10:00
parent dac233992a
commit 0e6f76c13d
2 changed files with 62 additions and 68 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2007, 2008 Alex Chapman ! Copyright (C) 2007, 2008 Alex Chapman
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays colors combinators kernel locals math math.constants math.matrices math.order math.ranges math.vectors math.quadratic random sequences specialized-arrays.float vectors jamshred.oint ; USING: accessors arrays colors combinators kernel literals locals math math.constants math.matrices math.order math.ranges math.vectors math.quadratic random sequences specialized-arrays.float vectors jamshred.oint ;
IN: jamshred.tunnel IN: jamshred.tunnel
CONSTANT: n-segments 5000 CONSTANT: n-segments 5000
@ -15,9 +15,7 @@ C: <segment> segment
{ 100 100 100 } [ random 100 / >float ] map first3 1.0 <rgba> ; { 100 100 100 } [ random 100 / >float ] map first3 1.0 <rgba> ;
CONSTANT: tunnel-segment-distance 0.4 CONSTANT: tunnel-segment-distance 0.4
USE: words.constant CONSTANT: random-rotation-angle $[ pi 20 / ]
DEFER: random-rotation-angle
\ random-rotation-angle pi 20 / define-constant
: random-segment ( previous-segment -- segment ) : random-segment ( previous-segment -- segment )
clone dup random-rotation-angle random-turn clone dup random-rotation-angle random-turn

View File

@ -1,7 +1,6 @@
! Copyright (C) 2007, 2008, 2009 Alex Chapman, 2009 Diego Martinelli ! Copyright (C) 2007, 2008, 2009 Alex Chapman, 2009 Diego Martinelli
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors ascii assocs biassocs combinators hashtables kernel lists math USING: accessors ascii assocs biassocs combinators hashtables kernel lists literals math namespaces make multiline openal parser sequences splitting strings synth synth.buffers ;
namespaces make multiline openal parser sequences splitting strings synth synth.buffers ;
IN: morse IN: morse
<PRIVATE <PRIVATE
@ -14,9 +13,8 @@ CONSTANT: unknown-char CHAR: ?
PRIVATE> PRIVATE>
DEFER: morse-code-table CONSTANT: morse-code-table $[
H{
H{
{ CHAR: a ".-" } { CHAR: a ".-" }
{ CHAR: b "-..." } { CHAR: b "-..." }
{ CHAR: c "-.-." } { CHAR: c "-.-." }
@ -72,10 +70,8 @@ H{
{ CHAR: $ "...-..-" } { CHAR: $ "...-..-" }
{ CHAR: @ ".--.-." } { CHAR: @ ".--.-." }
{ CHAR: \s "/" } { CHAR: \s "/" }
} >biassoc \ morse-code-table set-global } >biassoc
]
: morse-code-table ( -- biassoc )
\ morse-code-table get-global ;
: ch>morse ( ch -- morse ) : ch>morse ( ch -- morse )
ch>lower morse-code-table at [ unknown-char ] unless* ; ch>lower morse-code-table at [ unknown-char ] unless* ;