Binary digits: Difference between revisions

Content deleted Content added
Querfeld (talk | contribs)
→‎min: define 'bin' as a proper operator
Querfeld (talk | contribs)
→‎Joy: create a proper string for better reusability
Line 2,892: Line 2,892:
9000 -> 一〇〇〇一一〇〇一〇一〇〇〇</pre>
9000 -> 一〇〇〇一一〇〇一〇一〇〇〇</pre>
=={{header|Joy}}==
=={{header|Joy}}==
<syntaxhighlight lang="joy">HIDE
<syntaxhighlight lang="joy">DEFINE 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 put.</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}}==
=={{header|jq}}==
<syntaxhighlight lang="jq">def binary_digits:
<syntaxhighlight lang="jq">def binary_digits: