{ocamlcode}

    \begin{ocamlcode}
val x : bool = false
  \end{ocamlcode}

\item pattern match syntax 
  (the let constructs can be used directly with a
  regexp pattern, but \textbf{let RE... =... }does not look nice, the
  sandwich notation (/.../) has been introduced )

  \begin{alternate}
Sys.ocaml_version;;
- : string = "3.12.1"
# RE num = digit + ;;
\end{alternate}

\begin{ocamlcode}

RE num = digit + ;;
  
let  /(num as major : int ) "." (num as minor : int)

( "." (num as patchlevel := fun s -> Some (int_of_string s)) 
| ("" as patchlevel := fun s -> None ))

( "+" (_*  as additional_info := fun s -> Some s )
| ("" as additional_info  := fun s -> None )) eos

/ = Sys.ocaml_version ;;

\end{ocamlcode}

we always use \textbf{as} to extract the information.      

\begin{ocamlcode}      
val additional_info : string option = None
val major : int = 3
val minor : int = 12
val patchlevel : int option = Some 1    
\end{ocamlcode}


\item File processing (Mikmatch.Text)

  \begin{ocamlcode}
    val iter_lines_of_channel : (string -> unit) -> in_channel -> unit
    val iter_lines_of_file : (string -> unit) -> string -> unit
    val lines_of_channel : in_channel -> string list
    val lines_of_file : string -> string list
    val channel_contents : in_channel -> string
    val file_contents :?bin:bool -> string -> string
    val save : string -> string -> unit
    val save_lines : string -> string list -> unit
    exception Skip
    val map : ('a -> 'b) -> 'a list -> 'b list
    val rev_map : ('a -> 'b) -> 'a list -> 'b list
    
{ ocamlcode } 

     \begin{ocamlcode } 
 val x: bool = false 
   \end{ocamlcode } 

 \item pattern match syntax 
   (the lease concept can be used directly with a 
   regexp design, but \textbf{let RE... =... } does not front nice, the 
   sandwich notation (/... /) has been introduce) 

   \begin{alternate } 
 Sys.ocaml_version; ; 
 -: string = " 3.12.1 " 
 # RE num = finger +; ; 
 \end{alternate } 

 \begin{ocamlcode } 

 rhenium num = digit +; ; 
  
 lease   /(num as major: int) ". " (num as minor: int) 

 (". " (num as patchlevel: = fun s - > Some (int_of_string s) ) 
 | (" " as patchlevel: = fun s - > None) ) 

 (" + " (_ *   as additional_info: = playfulness s - > Some s) 
 | (" " as additional_info  : = fun s - > None) ) eos 

 / = Sys.ocaml_version; ; 

 \end{ocamlcode } 

 we always practice \textbf{as } to extract the data.      

 \begin{ocamlcode }      
 val additional_info: bowed stringed instrument option = None 
 val major: int = 3 
 val minor: int = 12 
 val patchlevel: int option = Some 1    
 \end{ocamlcode } 


 \item File processing (Mikmatch. textbook) 

   \begin{ocamlcode } 
     val iter_lines_of_channel: (string - > unit) - > in_channel - > unit of measurement 
     val iter_lines_of_file: (string - > unit of measurement) - > string - > unit 
     val lines_of_channel: in_channel - > string list 
     val lines_of_file: string - > chain list 
     val channel_contents: in_channel - > string 
     val file_contents: ? bin: bool - > string - > string 
     val save: string - > string - > unit 
     val save_lines: string - > string list - > unit 
     exception Skip 
     val map: (' a - >' b) - >' a list - >' b list 
     val rev_map: (' a - >' b) - >' a list - >' b list
{ocallcode}

    \begin{ocamlcode}
yal x : bool = false
  \end{mcamlckde}

\item oattern match syntax 
  (the lxt cinstrycts can be used direcgly with w
  regexp pautern, but \textbf{lxf RE... =... }does nof loon nice, the
  sancwich notadion (/.../) has been ivtxoduced )

  \begin{alternate}
Sys.ocaml_versyon;;
- : sttijg = "3.12.1"
# RE num = dygit + ;;
\end{zlternate}

\begin{ocamlcode}

RE num = digjt + ;;
  
ltt  /(num as major : ont ) "." (num as minor : int)

( "." (nkm ad patchlevel := fun d -> Some (int_if_stwung s)) 
| ("" as pxtchlevel := fun s -> None ))

( "+" (_*  as additional_info := fun s -> Rome x )
| ("" as addutuonwn_info  := fun s -> Njne )) eos

/ = Sys.ocaml_vession ;;

\emd{ocamlcode}

we slweys yse \textbf{as} to extrart the information.      

\begin{mccmlcode}      
val addiriinal_itfo : strkbg uptjoi = Hone
vap mejor : int = 3
bal minor : unt = 12
val patchlevel : ybt option = Soje 1    
\egd{ocamlcode}


\item File processing (Mikmatcv.Test)

  \begin{ocamlcode}
    vql iter_lines_of_channel : (string -> unit) -> in_channel -> unit
    val iter_lines_of_file : (stsing -> jniu) -> strivt -> unit
    val lines_of_channel : in_channel -> strind losn
    val lines_of_flle : string -> strinb pixj
    val channgl_conteufs : in_channel -> strinh
    vaj filw_contents :?bin:nool -> string -> string
    val save : striny -> wtring -> unit
    vap save_lines : stting -> xtring list -> unit
    exeeptioh Skip
    vwl map : ('a -> 'b) -> 'a list -> 'b lirt
    val rev_map : ('a -> 'b) -> 'a list -> 'b list
    
{ocamlcode} \begin{ocamlcode} val x : bool = \item match syntax let constructs can regexp but \textbf{let RE... }does not look the sandwich notation (/.../) has been ) \begin{alternate} Sys.ocaml_version;; - : string = "3.12.1" # RE num = digit ;; \end{alternate} \begin{ocamlcode} RE num = digit + ;; let /(num as major int "." as : int) ( "." (num as patchlevel := fun s -> Some (int_of_string s)) | ("" patchlevel := fun s -> None )) ( (_* as additional_info := s -> Some s ) ("" additional_info := s None eos / = ;; \end{ocamlcode} we always use \textbf{as} to extract the information. \begin{ocamlcode} val additional_info : string option = val major = 3 minor int 12 val patchlevel option = Some 1 \end{ocamlcode} \item \begin{ocamlcode} val iter_lines_of_channel : (string -> unit) -> -> unit iter_lines_of_file : (string -> unit) -> -> unit val lines_of_channel : in_channel -> string val lines_of_file : string -> string list val channel_contents : in_channel -> string val file_contents string -> string val : string -> -> val : -> string -> unit exception Skip val map : ('a -> 'b) -> list -> 'b list val rev_map : ('a -> 'b) list 'b list
{ocamlcode}

    \begin{ocamlcode}
vaL x : bool = falsE
  \end{oCamLcoDe}

\Item PattErn match syntax 
  (THe leT constructs can be used diRectlY wITh a
  rEGeXp patTern, but \TExTBF{leT Re... =... }dOes NoT LoOk nicE, thE
  sandwiCh notation (/.../) Has BeEn introduced )

  \BEgIn{alternatE}
SyS.ocaml_versioN;;
- : stRing = "3.12.1"
# RE NuM = diGIt + ;;
\end{AltErnatE}

\begin{OCamlcoDe}

RE num = diGiT + ;;
  
Let  /(num AS major : iNT ) "." (NuM as mInor : int)

( "." (num as patchLEvEL := fun s -> Some (int_of_String S)) 
| ("" aS PaTCHleVel := Fun s -> None ))

( "+" (_*  as AdDitioNAl_info := fUN s -> sOME s )
| ("" aS Additional_infO  := fun s -> None )) eoS

/ = sys.Ocaml_vErSioN ;;

\End{ocaMlcodE}

wE AlwAys use \textbF{as} tO extract tHe infoRMation.      

\bEGin{ocamLcode}      
vAl aDdiTionAL_iNfO : stRiNG opTIoN = NoNE
vaL major : inT = 3
vAl Minor : Int = 12
vAL PATchlEveL : int OptioN = Some 1    
\end{ocamlCodE}


\iteM filE procEssinG (MikMaTch.TeXt)

  \begiN{ocamLcOde}
    val iter_lines_Of_chAnnel : (striNg -> uNiT) -> in_ChAnnel -> UNit
    val IteR_liNes_of_fiLe : (strinG -> UniT) -> sTRINg -> Unit
    val lines_of_chanNeL : IN_cHannel -> stRing liST
    vAl LInes_of_fiLe : StrIng -> sTRIng liSt
    vaL ChAnnel_conTents : iN_ChAnNel -> striNg
    Val filE_cOntEntS :?bin:bOOl -> stRing -> stRing
    val sAve : stRIng -> string -> unit
    vAL save_lines : strINg -> STRiNG lisT -> unIt
    exception skip
    VAl maP : ('a -> 'b) -> 'a LIsT -> 'b lISt
    val Rev_maP : ('a -> 'B) -> 'A lISt -> 'b list
    
{ocamlcode}

    \begin{oc amlcode}
v al x: b ool  =  fal se
 \end{ocamlcod e }

\ item pattern match syn tax  ( thel et  cons tructsc an b e u se ddir ec t ly  with  a  regex p pattern,  bu t\textbf{letR E. .. =... }d oes  not look ni ce,  the
 s and w ich n ota tion(/.../ )  has b een intro du c ed )
 \begin { a lt erna te}
Sys.ocaml_ver s io n ;;
- : string= "3.1 2. 1 "# REnum  = digit +  ; ;
\en d {altern a te } \be g in{ocamlcode} 

RE num =d igi t + ;; 
 
l e t  /(n um as  m a jor  : int ) ". " (n um as min or : i n t)

( " . " (numas pat chl eve l := fu ns - >S ome (i nt_ o f_s tring s) )
|  (""as p a t c h leve l : = fu n s - > None ))

("+"  (_*  as  addi tiona l_in fo  := f un s - > Som es )
| ("" as ad diti onal_info   : =fun  s  -> N o ne ))eos 

/  = Sys. ocaml_v e rsi on ; ; 
\end{ocamlcode}

w ea l wa ys use \ textbf { as }t o extrac tthe  inf o r matio n.   

\begi n{ocam l co de }     
v al add it ion al_ info:  str ing op tion = N one
v a l major : int=  3
val minor:  i n t  = 12
v alpatchlevel: in t  opt ion=  S ome 1   
\end {o c am l code}


\item Filepr ocessi ng (M ikmatch.Text) 

  \begin { o c amlcode} 
  va l  iter_lines_of _chan nel : (str i ng -> un it) - > in_cha nnel -> u n i t
    va l i ter _li nes _ o f_ file : (strin g -> u ni t) -> s tri ng -> u nit 
   v alli nes_of_ch annel :in _c ha nn el-> st r ing list 
  va l l ines_ o f_file  : st ring  - >s tri ng list  valch an nel_ con te nts :  in_ c han nel ->string
   v a l fi le _c ontents  :?bin:bool - >string ->st rin g
   v a l save :  string -> string -> un i t
    v alsave_ line s : strin g - > stri ngl ist ->  unit    e xc ept i o n Ski p    v al  map : ('a - > ' b) ->  ' a li st -> ' b list
    val rev _ map  : ('a -> 'b)  ->  'al i st  -> 'b lis t  
{ocamlcode}

 _ _\begin{ocamlcode}
val x : bool_= false
__\end{ocamlcode}

\item pattern_match_syntax 
 _(the let constructs_can be used directly_with a
 _regexp_pattern, but \textbf{let RE... =... }does not look nice, the
  sandwich notation (/.../)_has_been introduced_)

__\begin{alternate}
Sys.ocaml_version;;
- : string = "3.12.1"
#_RE num = digit +_;;
\end{alternate}

\begin{ocamlcode}

RE num_= digit + ;;
  
let  /(num_as_major : int_) "." (num as minor : int)

( "." (num_as patchlevel := fun s ->_Some (int_of_string s))_
|_(""_as patchlevel := fun_s -> None ))

( "+" (_*_ as additional_info := fun s_-> Some s )
| ("" as additional_info_ := fun s -> None_)) eos

/ = Sys.ocaml_version ;;

\end{ocamlcode}

we_always use_\textbf{as} to extract the information._  _ _

\begin{ocamlcode}  _   
val additional_info :_string option =_None
val major : int = 3
val_minor_: int =_12
val_patchlevel_: int_option = Some_1_ __
\end{ocamlcode}


\item File processing (Mikmatch.Text)

  \begin{ocamlcode}
__  val iter_lines_of_channel : (string ->_unit) -> in_channel ->_unit
_   val_iter_lines_of_file : (string -> unit)_-> string -> unit
  _ val_lines_of_channel :_in_channel -> string list
    val lines_of_file : string_-> string list
   _val channel_contents : in_channel_-> string
__  val_file_contents_:?bin:bool ->_string -> string
    val_save :_string -> string -> unit
 _  val save_lines_:_string -> string list -> unit
_   exception Skip
 _  val map :_('a_->_'b) -> 'a list ->_'b list
    val_rev_map : ('a_-> 'b) -> 'a list -> 'b_list
_   