Odd and square numbers: Difference between revisions
Content added Content deleted
(Added Quackery.) |
(add OCaml) |
||
Line 522: | Line 522: | ||
121 169 225 289 361 441 529 625 729 841 961 |
121 169 225 289 361 441 529 625 729 841 961 |
||
</pre> |
</pre> |
||
=={{header|OCaml}}== |
|||
<syntaxhighlight lang="ocaml">let odd_square x = |
|||
if x land 1 = 0 |
|||
then None |
|||
else Some (x * x) |
|||
let () = |
|||
Seq.(ints 10 |> filter_map odd_square |> take_while ((>) 1000) |> iter (Printf.printf " %u"))</syntaxhighlight> |
|||
{{out}}<pre> 121 169 225 289 361 441 529 625 729 841 961</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |