The Computer Language
22.05 Benchmarks Game

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
OCaml native-code
version 4.14.0


Tue, 03 May 2022 18:56:50 GMT

MAKE:
mv revcomp.ocaml-2.ocaml revcomp.ocaml-2.ml
~/.opam/4.14.0/bin/ocamlopt -noassert -unsafe -fPIC -nodynlink -inline 100 -O3 unix.cmxa -ccopt -march=ivybridge 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/all-benchmarksgame/2000-benchmarksgame/nanobench/makefiles/u64q.programs.Makefile:344: revcomp.ocaml-2.ocaml_run] Error 2 (ignored)
rm revcomp.ocaml-2.ml

0.59s to complete and log all make actions

COMMAND LINE:
./revcomp.ocaml-2.ocaml_run 0 < revcomp-input250000.txt

MAKE ERROR