Base-16 representation: Difference between revisions

Content deleted Content added
Chunes (talk | contribs)
Add Factor
Chunes (talk | contribs)
→‎{{header|Factor}}: tweak non-decimal? again
Line 61: Line 61:


{{works with|Factor|0.99 2021-02-05}}
{{works with|Factor|0.99 2021-02-05}}
<lang factor>USING: combinators.short-circuit formatting grouping io kernel
<lang factor>USING: combinators formatting grouping io kernel lists
lists lists.lazy math prettyprint sequences ;
lists.lazy math prettyprint sequences ;


! Returns t if the hexadecimal representation of n contains a
! Returns t if the hexadecimal representation of n contains a
! non-decimal digit.
! non-decimal digit.
: non-decimal? ( n -- ? )
: non-decimal? ( n -- ? )
{
[ dup { [ 0xF bitand 10 < ] [ 0 > ] } 1&& ]
[ -4 shift ] while zero? not ;
{ [ dup zero? ] [ drop f ] }
{ [ dup 0xF bitand 9 > ] [ drop t ] }
[ -4 shift non-decimal? ]
} cond ;


1 lfrom [ non-decimal? ] lfilter [ 501 < ] lwhile
1 lfrom [ non-decimal? ] lfilter [ 501 < ] lwhile