restructure + lecutre 07
This commit is contained in:
96 files changed
+458
-4
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"Resource: /home/flami/Projects/comp3958/lecture05/number_lines.ml": "n\239\025\\<\011\028#\000A>\249\204\182\170r"
|
||||
"Rule: ocaml dependencies ml (%=cat )": "\210V\221`\251\191B\198\232\184\146#\164\015\176,"
|
||||
"Rule: ocaml: cmx* & o* -> native (%=number_file_lines )": "R|\021U[G\226zs:\214\154\1910a\177"
|
||||
"Rule: ocaml: ml & cmi -> cmx & o (%=cat )": "\025\244\2354\235@{lBk\211\031$\237><"
|
||||
"Rule: ocaml: cmx* & o* -> native (%=number_lines )": "\180K\170\211^n:g\196\220\030 \233\127*\149"
|
||||
"Rule: ocaml: cmx* & o* -> native (%=echo )": "\196\206\211\186\185&f\154\217p\215\195\248p\1485"
|
||||
"Resource: /home/flami/Projects/comp3958/lecture05/echo.ml": "h\001\167\215xe\171\150p\151\004p>\004%\181"
|
||||
"Rule: ocaml dependencies ml (%=sum_integers )": "\207\140\220\182.\186\127\200\228\226\152\002dAJ\134"
|
||||
"Rule: ocaml dependencies ml (%=echo )": "\237\219\161\187\134\217\180\030\148\240\0166\176W\2222"
|
||||
"Resource: /home/flami/Projects/comp3958/lecture05/sum_integers.ml": "#b[\196\162u!\202\205~\135\239\025i\195\215"
|
||||
"Rule: ocaml: ml -> cmo & cmi (%=sum_integers )": "\015x\165\015\217\024\189(\143ud\232#\158Um"
|
||||
"Rule: ocaml: cmx* & o* -> native (%=sum_integers )": "q.\011\170\190\228da(\218\172\231\192\136\236+"
|
||||
"Rule: ocaml: ml -> cmo & cmi (%=cat )": "\248U3\213\015A\001\180 \023\180>\223}\142\188"
|
||||
"Rule: ocaml: ml -> cmo & cmi (%=number_file_lines )": "\218\210>\023\150\016u\174\235\179&6\234\147\248\016"
|
||||
"Rule: ocaml: ml & cmi -> cmx & o (%=echo )": "\1770\n\142p\235j\205HX\163\208\005\133n\t"
|
||||
"Rule: ocaml: ml & cmi -> cmx & o (%=sum_integers )": "\024\022\151\178THu\229\251\017\175G\230\179rD"
|
||||
"Rule: ocaml dependencies ml (%=number_lines )": "\023O8\158;\213,z\t`\236\204\250\168\140W"
|
||||
"Resource: /home/flami/Projects/comp3958/lecture05/number_file_lines.ml": ":\233\133ai\245 \000\199f8\022\140<\199\174"
|
||||
"Resource: /home/flami/Projects/comp3958/lecture05/cat.ml": "^\135\t\199Rr\210]\197\127HpY\r\147\170"
|
||||
"Rule: ocaml: ml -> cmo & cmi (%=echo )": "\224\\C\014\150\004=\191p\132*-\017jj\242"
|
||||
"Rule: ocaml dependencies ml (%=number_file_lines )": "\142\151\154\251\184\227\201\196\243\150\003\242\017\222\229X"
|
||||
"Rule: ocaml: ml & cmi -> cmx & o (%=number_lines )": "l\154\251\180\134\026\206s\139\030!A\155\t\198\161"
|
||||
"Rule: ocaml: ml -> cmo & cmi (%=number_lines )": "\029\1849 z\004\n\025\253\155]\017\244\252\141\129"
|
||||
"Rule: ocaml: cmx* & o* -> native (%=cat )": "j\019\018\218,\202\215\161 &5SE\134\223/"
|
||||
"Rule: ocaml: ml & cmi -> cmx & o (%=number_file_lines )": "|\132>\000@\222\195L,\1271\1424\141wJ"
|
||||
@@ -0,0 +1,12 @@
|
||||
### Starting build.
|
||||
# Target: /home/flami/.opam/default/bin/ocamlc.opt -config, tags: { }
|
||||
/home/flami/.opam/default/bin/ocamlc.opt -config
|
||||
# Target: number_lines.ml.depends, tags: { extension:ml, file:number_lines.ml, ocaml, ocamldep, quiet }
|
||||
/home/flami/.opam/default/bin/ocamldep.opt -modules number_lines.ml > number_lines.ml.depends
|
||||
# Target: number_lines.cmo, tags: { byte, compile, extension:cmo, extension:ml, file:number_lines.cmo, file:number_lines.ml, implem, ocaml, quiet }
|
||||
/home/flami/.opam/default/bin/ocamlc.opt -c -o number_lines.cmo number_lines.ml
|
||||
# Target: number_lines.cmx, tags: { compile, extension:cmx, extension:ml, file:number_lines.cmx, file:number_lines.ml, implem, native, ocaml, quiet }
|
||||
/home/flami/.opam/default/bin/ocamlopt.opt -c -o number_lines.cmx number_lines.ml
|
||||
# Target: number_lines.native, tags: { dont_link_with, extension:native, file:number_lines.native, link, native, ocaml, program, quiet }
|
||||
/home/flami/.opam/default/bin/ocamlopt.opt number_lines.cmx -o number_lines.native
|
||||
# Compilation successful.
|
||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
(* display content of file read via stdin *)
|
||||
let rec cat () =
|
||||
try
|
||||
let line = read_line () in
|
||||
print_endline line;
|
||||
cat()
|
||||
with
|
||||
| _ -> ();; (* EOF return unit *)
|
||||
|
||||
(* similar to main function *)
|
||||
let () =
|
||||
let rec aux () =
|
||||
try
|
||||
print_endline @@ read_line ();
|
||||
aux ()
|
||||
with
|
||||
| _ -> ()
|
||||
in
|
||||
aux()
|
||||
|
||||
(**** build and test ****)
|
||||
(*
|
||||
ocamlbuild cat.native
|
||||
./cat.native < filename
|
||||
*)
|
||||
@@ -0,0 +1 @@
|
||||
cat.ml:
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
let () =
|
||||
let len = Array.length Sys.argv - 1 in
|
||||
for i = 1 to len do
|
||||
Printf.printf (if i <> len then "%s " else "%s\n") Sys.argv.(i)
|
||||
done;;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
echo.ml: Array Printf Sys
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
let rec number acc ic =
|
||||
try
|
||||
Printf.printf "%5d| %s\n" acc @@ input_line ic;
|
||||
number (acc + 1) ic
|
||||
with
|
||||
| _ -> if ic <> stdin then close_in ic else ()
|
||||
|
||||
let () =
|
||||
if Array.length Sys.argv = 1 then
|
||||
number 1 stdin
|
||||
else
|
||||
try
|
||||
number 1 @@ open_in Sys.argv.(1)
|
||||
with
|
||||
| Sys_error s -> Printf.eprintf "%s\n" s;;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
number_file_lines.ml: Array Printf Sys
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
let () =
|
||||
let rec aux acc =
|
||||
try
|
||||
Printf.printf "%5d| %s\n" acc @@ read_line ();
|
||||
aux (acc + 1)
|
||||
with
|
||||
| _ -> ()
|
||||
in
|
||||
aux 1;;
|
||||
@@ -0,0 +1 @@
|
||||
number_lines.ml: Printf
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
let () =
|
||||
let rec aux sum =
|
||||
try
|
||||
aux @@ Scanf.scanf " %d" (fun x -> sum + x)
|
||||
with
|
||||
| Scanf.Scan_failure _ ->
|
||||
Scanf.scanf " %s" (fun _ -> ());
|
||||
aux sum
|
||||
| End_of_file -> sum
|
||||
in
|
||||
Printf.printf "%d\n" @@ aux 0;;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
sum_integers.ml: Printf Scanf
|
||||
Binary file not shown.
Reference in new issue
Block a user