Handbook
Glossary
fix-sign ( string -- string )
Vocabulary
formatting
.
private
Inputs
string
an
object
Outputs
string
an
object
Definition
USING:
combinators
kernel
math
sequences
unicode
;
IN:
formatting.private
:
fix-sign
( string -- string )
dup
first
48
=
[
dup
[
[
48
=
not
]
[
digit?
]
bi
and
]
find
[
1
-
swap
2dup
nth
{
{
45
[
remove-nth
"-"
prepend
]
}
{
43
[
remove-nth
"+"
prepend
]
}
[
drop
nip
]
}
case
]
[
drop
]
if
]
when
;