Binary digits: Difference between revisions

→‎Joy: create a proper string for better reusability
(→‎min: define 'bin' as a proper operator)
(→‎Joy: create a proper string for better reusability)
Line 2,892:
9000 -> 一〇〇〇一一〇〇一〇一〇〇〇</pre>
=={{header|Joy}}==
<syntaxhighlight lang="joy">HIDEDEFINE bin == "" [pop 1 >] [[2 div "01" of] dip cons] while ["01" of] dip cons.
 
_ == [null] [pop] [2 div swap] [48 + putch] linrec
[0 1 2 5 50 9000] [bin] map int2binput.</syntaxhighlight>
IN
{{out}}
int2bin == [null] [48 + putch] [_] ifte '\n putch
<pre>["0" "1" "10" "101" "110010" "10001100101000"]</pre>
END</syntaxhighlight>
 
Using int2bin:
<syntaxhighlight lang="joy">0 setautoput
0 int2bin
5 int2bin
50 int2bin
9000 int2bin.</syntaxhighlight>
=={{header|jq}}==
<syntaxhighlight lang="jq">def binary_digits:
559

edits