if (p:string list) = c (is the only element)

if (p:string list) = [c] then (divide p1 c)
showing unbound value c.
i want to equalise (if one element in p which is (c:anything)) and use that variable

let p = ["ocaml"]
let f s = match s with
  | [c] -> print_endline c
  | _ -> print_endline "ops"
f p

It will print:

ocaml

If you like Scala:

scala> def f(s: List[String]): Unit = {
     | s match {
     | case List(c) => print(c)
     | case _ => print("ops")
     | }
     | }
f: (s: List[String])Unit

scala> val p = List("Scala")
p: List[java.lang.String] = List(Scala)

scala> f(p)
Scala

Similar Posts

  • How to configure iptables on Linux Mint 17.1?

    How to configure iptables and make the configuration persistent across system restarting on Linux Mint 17.1? You can use the ‘iptables-persistent’ tool. To install iptables-persistency pachage: sudo aptitude install iptables-persistent The you can manipulate the iptables by the ‘iptables’ command. To save the current iptables rules: sudo /etc/init.d/iptables-persistent store It will store the rules for…

  • How to convert flv to mp4 with ffmpeg?

    How to convert a video file in format as flv to mp4 with ffmpeg? You may use method from here: https://www.systutorials.com/3540/converting-video-files-for-ipod-iphone-ipad/ ffmpeg -i input.flv output.mp4 Or by specifying more details about how to handling the codecs: ffmpeg -i input.flv -vcodec copy -acodec copy output.mp4 You may also add more options as you like. For more,…

  • SetProxy: 一个设置IE代理的命令行小工具

    IE的代理设置用起来并不方便,我自己而言就要经常更改代理服务器,相信很多人有跟我相同的需要。使用C++编写了一个小程序SetProxy调用Win32 API来设置代理服务器IP,用起来方便多了。 编译后为一个可运行console程序,将它放在\windows\system32目录下,使用时只要运行 SetProxy IP:port 就可以把IP设置好,如果要关闭代理,只需运行 SetProxy “” 命令行中运行,界面较土,但用着方便。可以考虑设置几个快捷方式在桌面或者工具栏,点击即设置代理,其它方式发挥想象。 程序下载地址. 源代码也放在这里,希望有需要的人可以用得上 ;) 源代码下载地址. 这是一份有些年头的代码, 如果你在较新的编译器下编译这个项目, 请先做[[setproxy-一个设置ie代理的小工具#comment-995|这里所述的小修改]]. — Eric on Apr. 9, 2014. Read more: Making Emacs Start Up Faster Profiling Vim to Find Out Which Plugin Makes Vim Slow Handling Sparse Files on Linux Spring Shell Technology For Java development Vim Tutorial for Beginners: vimtutor…

  • How to use different keys for different git servers?

    I have access to different git servers. I have several keys for these servers. How to use different keys for different git servers? Use the .ssh/config file to specify different configuration for different SSH servers used by git: For example: Host git.example.org Port 22111 IdentityFile ~/.ssh/id_rsa.git.example.org Host code.example.org Port 22 IdentityFile ~/.ssh/id_rsa.code.example.org which specifies the…

  • How to change default OS for windows dual boot manager in Windows 7?

    How to change default OS for windows dual boot manager in Windows 7? The c:/boot/ in older Windows does not exist anymore. Open the Control Panel and click on the System icon. In the left pane, click on the Advanced system settings link. Under the Advanced tab, click on the Settings button under Startup and…

Leave a Reply

Your email address will not be published. Required fields are marked *