Quick actions

cmd+k|ctrl+k

Navigation

Languages

Convert number to binary string functional style

Snippet info

Language

Raku

Visibility

public

Author

slu

Created

2017-03-22T09:06:59Z

Updated

2017-03-22T09:08:09Z

sub binary($n) {
	return $n if $n == 0 | 1;
	return binary($n+>1) ~ $n%2;
}

(0,45,2,45,255,1).map(-> $n { ($n, binary($n)) }).sort>>.join("\t")>>.say;
INFO