博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ocaml_如何使用OCaml作为脚本语言?
阅读量:2522 次
发布时间:2019-05-11

本文共 1651 字,大约阅读时间需要 5 分钟。

ocaml

How to use as a script language like bash and python? It will be good that I can write a script in OCaml and directly invoke it.

如何使用作为bash和python等脚本语言? 我可以在OCaml中编写脚本并直接调用它会很好。

For example, I write a script named “script.ml” and then I can invoke it directly by

例如,我编写了一个名为“ script.ml”的脚本,然后可以通过直接调用它

$ ./script.ml

Thanks!

谢谢!

Three helloworld scripts:

三个helloworld脚本:

script3.ml

script3.ml

#! /usr/bin/env ocamlprint_string "Hello world!n";;

script1.ml:

script1.ml:

#! /bin/ocamlprint_string "Hello world!n";;

script2.ml

script2.ml

#! /bin/sh# (*exec ocaml "$0" "$@"*) use "topfind";;print_string "Hello world!n";;

Idea from .

来自想法。

Remember to make the executable by

记得通过以下方式使可执行文件

chmod 755 script.ml

I prefer script3.ml. The script1.ml is straightforward, but it is bounded to /bin/ocaml for the ocaml command. The script2.ml is more complex, but use your environmental configuration for the location of the ocaml command.

我更喜欢script3.ml。 script1.ml很简单,但是对于ocaml命令,它已绑定到/bin/ocaml 。 script2.ml较为复杂,但是请使用您的环境配置作为ocaml命令的位置。

Also be aware that the overall source code is compiled in total first and then is executed. Hence, no execution happens if there is some , such as failures to compile the script. This is different from a bash script that will be executed by the interpreter until there is an error happens.

还应注意,总体源代码将首先全部编译,然后再执行。 因此,如果存在某些 (例如无法编译脚本),则不会执行任何操作。 这与解释器将在错误发生之前执行的bash脚本不同。

There are other discussions and on using OCaml as a scripting language:

关于使用OCaml作为脚本语言还有其他讨论和 :

.

.

Answered by anonymous.
匿名回答。


Most preferred script:

最喜欢的脚本:

$ cat script3.ml #! /usr/bin/env ocamlprint_string "Hello world!n";;

翻译自:

ocaml

转载地址:http://nmowd.baihongyu.com/

你可能感兴趣的文章
win7(64位)php5.5-Apache2.4-mysql5.6环境安装
查看>>
同一行内不同大小的字体垂直居中
查看>>
【翻译】(13)Prebuilts
查看>>
C++中的单例模式(转)
查看>>
使用ptrace向已运行进程中注入.so并执行相关函数(转)
查看>>
Android 9 patch 图片 (.9.png 格式图片) 的特点和制作(转)
查看>>
CentOS7系统安装 Maria Db(MYSQL)教程
查看>>
三十四.MySQL主从同步 、主从同步模式
查看>>
zk 的配额
查看>>
openstack Icehouse发布
查看>>
这是第四版本 到了第五个版本我的程序代码大改了 效果很好 期待我再升级...
查看>>
一步步学习SPD2010--第十章节--SP网站品牌化(1)--设置CSS和颜色编码页面编辑器选项...
查看>>
[LeetCode] Template to N Sum for (LC 15. 3Sum, LC 18. 4Sum)(N>2)
查看>>
20171130-构建之法:现代软件工程-阅读笔记
查看>>
二维数组与排序
查看>>
loadrunner设置Analysis分析时去掉思考时间
查看>>
FPGA跨时钟域异步时钟设计的几种同步策略
查看>>
ORA-01113: file xxxx needs media recovery
查看>>
MySQL表的碎片整理和空间回收小结
查看>>
web.xml不认<taglib>解决办法(转)
查看>>