I am struggling to convert integer to string in Factor language.
I have tried the below and few more very similar, but unable to find any guideline for Factor language. The only one I have found is this one, but I struggle with it: https://andreaferretti.github.io/factor-tutorial/
USING: kernel ;
IN: number-to-string
: number-to-string ( n -- str )
[ "%d" format ] dip >string ;
USING: kernel ;
IN: number-to-string
: number-to-string ( n -- str )
"%d" sprintf ;
IN: number-to-string
: number-to-string ( n -- str ) >string ;
USING: strings ;
IN: number-to-string
: number-to-string ( n -- str )
number>string ;
This is the test case I am using
USING: number-to-string tools.testest ;
IN: number-to-string.tests
: run-tests ( -- )
"Fixed tests" describe#{
"should satisfy fixed tests" it#{
<{ 67 number-to-string -> "67" }>
}#
}#
;
MAIN: run-tests
I have managed to find reason why it did not work. This code works. There was missing vocabulary math.parser.
USING: math.parser ;
IN: number-to-string
: number-to-string ( n -- str )
number>string ;