Commits

hogekura committed 4931ef4

OMake化

  • Participants
  • Parent commits fb6f009

Comments (0)

Files changed (8)

+BYTE_ENABLED = true
+NATIVE_ENABLED = false
+USE_OCAMLFIND = true
+
+.SUBDIRS: src
+########################################################################
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this file, to deal in the File without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the File, and to permit persons to whom the
+# File is furnished to do so, subject to the following condition:
+#
+# THE FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE FILE OR
+# THE USE OR OTHER DEALINGS IN THE FILE.
+
+########################################################################
+# The standard OMakeroot file.
+# You will not normally need to modify this file.
+# By default, your changes should be placed in the
+# OMakefile in this directory.
+#
+# If you decide to modify this file, note that it uses exactly
+# the same syntax as the OMakefile.
+#
+
+#
+# Include the standard installed configuration files.
+# Any of these can be deleted if you are not using them,
+# but you probably want to keep the Common file.
+#
+open build/C
+open build/OCaml
+open build/LaTeX
+
+#
+# The command-line variables are defined *after* the
+# standard configuration has been loaded.
+#
+DefineCommandVars()
+
+#
+# Include the OMakefile in this directory.
+#
+.SUBDIRS: .
+.SUBDIRS: be
+
+OCAMLINCLUDES += ./be
+OCAMLFLAGS += -thread -linkpkg
+OCAMLFINDFLAGS = -pp 'camlp4of -I ./be bool_quot.cma' -package core
+
+OCamlProgram(problems, problems)
+.DEFAULT: problems.run
+OCAMLFINDFLAGS = -syntax camlp4o -package camlp4,camlp4.metagenerator,camlp4.extend,camlp4.quotations.o
+
+OCamlProgram (be_ast, be_ast)
+OCamlProgram (be_quot, be_quot)
+OCamlLibrary (bool_quot, be_ast be_quot)

src/be/be_quot.ml

 let bool_expr_eoi = Gram.Entry.mk "bool_expr_eoi" ;;
 
 EXTEND Gram
-  bool_expr_eoi : [[ b = bool_expr; EOI -> b ]];
+  bool_expr_eoi : [[ b = bool_expr; `EOI -> b ]];
 END ;;
 
 let parse_quot_string loc s =

src/be/make.sh

-#!/bin/sh
-
-ocamlfind ocamlc -syntax camlp4o -linkpkg -package camlp4,camlp4.metagenerator -c be_ast.ml &&
-ocamlfind ocamlc -syntax camlp4o -linkpkg -package camlp4.quotations,camlp4.metagenerator,camlp4.extend -c be_quot.ml &&
-ocamlfind ocamlc -a -o bool_quot.cma be_ast.cmo be_quot.cmo

src/make.sh

-cd ./be; ./make.sh; cd ../;
-ocamlfind ocamlc -I ./be -pp 'camlp4of -I ./be bool_quot.cma' -thread -linkpkg -package core,camlp4 -c problems.ml
 ;;
 
 let sym_cbal_tree n =
-  cbal_tree n |> List.filter ~f:is_symmetric ;;
+  cbal_tree n |> List.filter ~f:is_symmetric
+;;
+
+let rec map2 xs ~f =
+  let open List.Monad_infix in
+  match xs with
+  | x :: xs -> List.map xs ~f:(f x) @ map2 xs ~f
+  | [] -> []
+;;
+
+let rec hbal_tree n =
+  let open List.Monad_infix in
+  if n <= 0 then [Empty]
+  else if n = 1 then [Node ('x', Empty, Empty)]
+  else
+    let sub1 = hbal_tree (n - 1) in
+    let sub2 = hbal_tree (n - 2) in
+    (map2 sub1 ~f:(fun s1 s2 -> [Node ('x', s1, s2); Node ('x', s2, s1)]) |> List.concat) @
+    (sub1 >>= fun s1 ->
+     sub2 >>= fun s2 ->
+     [Node ('x', s2, s1); Node ('x', s1, s2)])
+;;