reverse-complement OCaml #2 program
source code
(* The Computer Language Benchmarks Game
* https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
contributed by Ingo Bormuth <ibormuth@efil.de>
*)
open String;;
let t, b, bi = make 256 ' ', make 61 '\n', ref 1;;
blit "TVGHEFCDIJMLKNOPQYSAABWXRZ" 0 t 65 26; blit t 65 t 97 26;
let rec rd ls =
let l, q = try input_line stdin, false with _ -> "", true in
if l <> "" && l.[0] <> '>' then rd (l::ls)
else (
let rec wr = function
s::ss ->
for si = length s - 1 downto 0 do
b.[!bi] <- t.[Char.code s.[si]];
if !bi<60 then bi:=!bi+1 else ( print_string b; bi:=1 )
done;
wr ss
| [] ->
if !bi>1 then output stdout b 0 !bi;
bi:=1 in
wr ls;
print_string ( if ls<>[] then ("\n"^l) else l );
q || rd []
) in
rd []
notes, command-line, and program output
NOTES:
64-bit Ubuntu quad core
The OCaml native-code compiler, version 4.10.0
Tue, 05 May 2020 23:18:41 GMT
MAKE:
mv revcomp.ocaml-2.ocaml revcomp.ocaml-2.ml
/opt/src/ocaml-4.10.0/bin/ocamlopt -noassert -unsafe -fPIC -nodynlink -inline 100 -O3 unix.cmxa -ccopt -march=core2 revcomp.ocaml-2.ml -o revcomp.ocaml-2.ocaml_run
File "revcomp.ocaml-2.ml", line 10, characters 36-37:
10 | blit "TVGHEFCDIJMLKNOPQYSAABWXRZ" 0 t 65 26; blit t 65 t 97 26;
^
Error: This expression has type string but an expression was expected of type
bytes
make: [/home/dunham/8000-benchmarksgame/nanobench/makefiles/u64q.programs.Makefile:320: revcomp.ocaml-2.ocaml_run] Error 2 (ignored)
rm revcomp.ocaml-2.ml
1.02s to complete and log all make actions
COMMAND LINE:
./revcomp.ocaml-2.ocaml_run 0 < revcomp-input250000.txt
MAKE ERROR