- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图更好地理解函数式编码方式,并编写了一个小程序来打印回用户输入数字的阶乘:
open System
let fact n = let rec factiter init acc =
if init = 0 then acc
else factiter (init - 1) init*acc
factiter n 1
let dropStrArr (argv: string []) = ignore argv
let factComp = Console.ReadLine >> Int32.Parse >> fact >> Console.WriteLine >> fun () -> 0
[<EntryPoint>]
let main argv = (dropStrArr >> factComp) argv
main
可以纯粹由组合定义并尝试:
let main = dropStrArr >> factComp
unit -> int
当 main 用它的参数定义时,与
(unit -> int)
使用组合时。
最佳答案
简短的回答是在 F# 中编写无点样式会产生后果。
部分应用的函数被编译为 FSharpFunc
并随后用 Invoke
调用.
为了显示:
let mul a b = a + b
let mul2 = mul 2 //point-free
let mul2P a = mul 2 a //pointed
mul2P
看起来像你期望的(在等效的 C# 中)
static int mul2P(int a) { return mul(2, a); }
mul2
变成
class mul2Impl : FSharpFunc<int, int>
{
public int a;
mul2Impl(int a) { this.a = a; }
public override int Invoke(int b)
{
return mul(this.a, b);
}
}
let main argv
它变成了一个简单的静态方法,只调用另外两个
FSharpFunc
和
factComp.Invoke(dropStrArr.Invoke(argv));
main
变成
FSharpFunc
没有更多
a static main method as is required .
关于f# - 在 F# 中通过组合定义 EntryPoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41604526/
这个问题在这里已经有了答案: How to pass ARG value to ENTRYPOINT? (5 个答案) 关闭 3 年前。 我试图将参数传递到我的 docker 入口点,但它失败了,这
我正在尝试使用以下方法初始化运行Postgres的容器 FROM postgres:9.6 COPY my.backup /docker-entrypoint-initdb.d/ 在我的Dockerf
我在尝试启动我的应用程序时看到以下错误... > css-modules@1.0.0 start /Users/johnnynolan/Repos/css-modules webpack && ope
当我运行时:docker run --name mongodb -p 27107:27107 mongo --noauth --bind_ip=0.0.0.0 我总是得到这个错误:error: exe
我需要在ENTRYPOINT [..]上运行以下命令: dotnet reportgenerator -reports:coverage.cobertura.xml -targetdir:Report
我在理解或看到将bash脚本用作Docker容器的切入点时遇到问题。我已经尝试了很多东西了大约5个小时。 即使从此official Docker blog,使用bash脚本作为入口点仍然不起作用。 D
我有一个没有 UI 的 GWT 实用程序模块(因此,没有从 com.google.gwt.core.client.EntryPoint 继承的类。当我尝试使用 GWT 1.7.1 编译此模块时,我收到
我试图了解 ENTRYPOINT 之间的差异在 Dockerfile 和 docker run --entrypoint 中. exec ENTRYPOINT的表格允许多个参数, # Source:
我有一个入口点,如下所示 ENTRYPOINT /usr/bin/java ... /usr/path/$FILE 我试图在启动容器时传递一个环境变量 -e FILE=myfile.txt 但是这个值
我想以root用户身份启动nginx和cron,以1001用户身份启动php-fpm。我怎样才能做到这一点?我以为我必须创建一个入口点脚本,在其中我使用su-exec并以root身份启动nginx和c
我已经研究过在WordPress docker镜像中添加WordPress插件,因为在研究中我发现可以在docker-entrypoint.sh文件中添加自定义插件。但是我无法在入口点文件中添加自定义
我必须遵循(简单的)Dockerfile: FROM microsoft/windowsservercore:latest SHELL ["powershell", "-Command", "$Err
我正在尝试使用 ENTRYPOINT,但每当我这样做时,我都会收到一个错误,因为 no such file or directory docker 文件: FROM ubuntu:18.04 COPY
我是Docker的新手。尝试使用Transmission建立小图像。 这是我的 Dockerfile : #base image FROM alpine:latest #install Transmi
有没有办法使用 Dockerfile 在容器停止时运行命令?或在 docker-compose.yml使用 Docker 撰写?本质上,我想要一个在容器导出上运行的命令(与 ENTRYPOINT 相对
我正在使用 Dockerfile 构建自定义图像.显然,新的运行工作正常,但是当我停止容器并重新启动它时 - 它没有启动并保持在 的状态0号导出 . 该图像由 apache2 和一堆用于 symfon
我正在运行以下命令来通过命令行设置入口点以使用此容器启动Nginx服务 root @ server:〜#docker run -it --entrypoint =“/ bin / bash /root
我想在我的 docker-entrypoint.sh 上运行几个脚本; 我的问题是它是否有任何区别,如果有,推荐的解决方法是什么,关于以下选项: 一个 . ${HOMEDIR}/myscript --
我在将环境变量导出到 docker 入口点文件时遇到了一些问题。 这是我的 docker 文件内容: FROM ubuntu:16.04 ADD entrypoint.sh . RU
我正在尝试设置一个 django 项目并对其进行 dockerize。 我在运行容器时遇到问题。 据我所知,abe 构建成功,但运行失败。 这是我得到的错误: ERROR: for web Canno
我是一名优秀的程序员,十分优秀!