IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    [原]ocaml学习随笔-1

    u010255642发表于 2017-03-08 21:54:06
    love 0

    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" 




沪ICP备19023445号-2号
友情链接