Portál AbcLinuxu, 13. července 2025 07:37
open Core.Std (match String.is_prefix "Hello World" "Hello" with | true -> "Má" |_ -> "Nemá") |> Printf.printf "%s preffix"A kompilujem to takto:
ocamlc -o hello hello.ml
Potreboval by som tam pridat module core. Ktory uz mam stiahnuty cez OPAM. Ale vobec nemam skusenosti s makefilami ani inymi buildovacimi nastrojmi v linuxe.
Řešení dotazu:
open Core.Std;; let is_in text have = if (String.is_prefix text have) then "have" else "no-have";; Printf.printf "%s\n" (is_in "hello" "lo");;Makefile
SOURCE=hello.ml PROGRAM=hello $(PROGRAM): $(SOURCE) ocamlfind ocamlc -linkpkg -thread -package core $(SOURCE) -o $(PROGRAM) s: @echo "You must run:\n eval \`opam config env\`" setting: @echo "You must run:\n eval \`opam config env\`" clean: rm -f $(PROGRAM) $(PROGRAM).cmi $(PROGRAM).cmo run: @./$(PROGRAM)Pred prekladom
open Core.Std;; let is_in text have = if (String.is_prefix text have) then "have" else "no-have";; Printf.printf "%s\n" (is_in "hello" "lo");;Makefile
SOURCE=hello.ml PROGRAM=hello $(PROGRAM): $(SOURCE) ocamlfind ocamlc -linkpkg -thread -package core $(SOURCE) -o $(PROGRAM) s: @echo "You must run:\n eval \`opam config env\`" setting: @echo "You must run:\n eval \`opam config env\`" clean: rm -f $(PROGRAM) $(PROGRAM).cmi $(PROGRAM).cmo run: @./$(PROGRAM)Pred prekladom
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.