Two identical strings: Difference between revisions

(→‎OCaml: add)
Line 10:
=={{header|11l}}==
{{trans|Python}}
 
<syntaxhighlight lang="11l">F bits(=n)
‘Count the amount of bits required to represent n’
Line 912 ⟶ 911:
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="rebol">loop 0..1000 'i [
bin: as.binary i
Line 1,208 ⟶ 1,206:
LOOP
END</syntaxhighlight>
 
 
=={{header|BCPL}}==
Line 2,180 ⟶ 2,177:
990 1111011110
</pre>
 
 
 
 
=={{header|FutureBasic}}==
Line 2,554 ⟶ 2,548:
[957,"1110111101"]
[990,"1111011110"]</pre>
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">function twoidenticalstringsinbase(base, maxnum, verbose=true)
Line 2,915 ⟶ 2,910:
957 1110111101
990 1111011110</pre>
 
=={{header|OCaml}}==
<syntaxhighlight lang="ocaml">let rec bin_of_int = function
| n when n < 2 -> string_of_int n
| n -> Printf.sprintf "%s%u" (bin_of_int (n lsr 1)) (n land 1)
 
let seq_task =
let rec next n l m () =
if n = l
then next n (l + l) (succ (l + l)) ()
else Seq.Cons (n * m, next (succ n) l m)
in next 1 2 3
 
let () =
let show n = Printf.printf "%u: %s\n" n (bin_of_int n) in
seq_task |> Seq.take_while ((>) 1000) |> Seq.iter show</syntaxhighlight>
{{out}}
<pre>
3: 11
10: 1010
15: 1111
36: 100100
45: 101101
54: 110110
63: 111111
136: 10001000
153: 10011001
170: 10101010
187: 10111011
204: 11001100
221: 11011101
238: 11101110
255: 11111111
528: 1000010000
561: 1000110001
594: 1001010010
627: 1001110011
660: 1010010100
693: 1010110101
726: 1011010110
759: 1011110111
792: 1100011000
825: 1100111001
858: 1101011010
891: 1101111011
924: 1110011100
957: 1110111101
990: 1111011110
</pre>
 
=={{header|Pascal}}==
Line 3,439 ⟶ 3,483:
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="quackery"> [ 2 base put
number$ dup size 2 / split =
559

edits