utop # let rec my_listprint items =
match items with
|first::the_rest->printf "%s\n" first;
my_listprint the_rest
|[]->""
;;
val my_listprint : string list -> string = <fun> ─( 21:48:03 )─< command 27 >─────────────────────────────────────{ counter: 0 }─utop # my_listprint ["aaa";"nnnn";"bbbb"];;
aaa
nnnn
bbbb
- : string = "" ─( 21:48:13 )─< command 28 >─────────────────────────────────────{ counter: 0 }─utop #
utop # let my_first items=match
items with
|first::the_rest->first
|[]->"null"(*空*)
;;
val my_first : string list -> string = <fun> ─( ─( 20:35:09 )─< command 3 >──────────────────────────────────────{ counter: 0 }─
utop # my_first ["one";"two";"three";"four"];;
- : string = "one"