加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

haskell和Unix shell脚本

发布时间:2020-12-15 18:24:39 所属栏目:安全 来源:网络整理
导读:是否有可能在unix shell脚本中使用 haskell函数? 例如: #!/bin/bash...var1=value...# use haskell function with input from shell variable var1# and store the result into another shell variable var2var2=haskellFunction $var1... 我想在shell脚本
是否有可能在unix shell脚本中使用 haskell函数?

例如:

#!/bin/bash

...
var1=value
...

# use haskell function with input from shell variable var1
# and store the result into another shell variable var2

var2=haskellFunction $var1

...

我想在shell脚本中使用变量作为haskell函数的参数和结果

提前致谢.

吉米

使用 the -e switch to ghc,例如
var2=$(ghc -e "let f x = x*x + x/2 in f $var1")

对于字符串处理,最好将Haskell’s interact与bash的字符串结合使用:

var2=$(ghc -e 'interact reverse' <<<$var1)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读