The Computer Language
Benchmarks Game

reverse-complement OCaml #2 program

source code

(* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/

   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.06.0


Mon, 26 Mar 2018 23:42:56 GMT

MAKE:
mv revcomp.ocaml-2.ocaml revcomp.ocaml-2.ml
/opt/src/ocaml-4.06.0/bin/ocamlopt -noassert -unsafe -fPIC -nodynlink -inline 100 -O3 unix.cmxa revcomp.ocaml-2.ml -o revcomp.ocaml-2.ocaml_run
File "revcomp.ocaml-2.ml", line 10, characters 36-37:
Error: This expression has type string but an expression was expected of type
         bytes
/home/dunham/benchmarksgame/nanobench/makefiles/u64q.programs.Makefile:429: recipe for target 'revcomp.ocaml-2.ocaml_run' failed
make: [revcomp.ocaml-2.ocaml_run] Error 2 (ignored)
rm revcomp.ocaml-2.ml

0.81s to complete and log all make actions

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

MAKE ERROR