Data update

This commit is contained in:
Ingy döt Net 2024-03-06 22:25:12 -08:00
parent ed705008a8
commit 0df55f9f24
2196 changed files with 32999 additions and 3075 deletions

View file

@ -1,14 +1,11 @@
func$ bin num .
b$ = ""
if num = 0
b$ = "0"
.
while num > 0
while num > 1
b$ = num mod 2 & b$
num = num div 2
.
return b$
return num & b$
.
print bin 2
print bin 5
print bin 50
print bin 9000

View file

@ -3,7 +3,7 @@ import extensions;
public program()
{
new int[]{5,50,9000}.forEach:(n)
new int[]{5,50,9000}.forEach::(n)
{
console.printLine(n.toString(2))
}

View file

@ -0,0 +1,15 @@
$ENTRY Go {
= <Prout <Binary 5>
<Binary 50>
<Binary 9000>>;
};
Binary {
0 = '0\n';
s.N = <Binary1 s.N> '\n';
};
Binary1 {
0 = ;
s.N, <Divmod s.N 2>: (s.R) s.D = <Binary1 s.R> <Symb s.D>;
};

View file

@ -0,0 +1,6 @@
binstr : Int * -> Str
binstr = \n ->
if n < 2 then
Num.toStr n
else
Str.concat (binstr (Num.shiftRightZfBy n 1)) (Num.toStr (Num.bitwiseAnd n 1))