小编fre*_*ior的帖子

列表中的最后一个元素使用ocaml List.fold_left

我可以通过以下代码找到列表的最后一个元素.

let last (xs:'a list) : 'a =
    let rec aux xs prev =
        match xs with
        | [] -> prev
        | x::ys -> aux ys x in
    match xs with
    | [] -> failwith "no element"
    | x::xs -> aux xs x
Run Code Online (Sandbox Code Playgroud)

如何使用List.fold_leftOCaml中的函数找到同一列表的最后一个元素?提前致谢!

ocaml functional-programming list

5
推荐指数
1
解决办法
2221
查看次数

在 python 套接字中为 socket.connect() 指定源 IP 地址

当我们__socket.connect((host, port))在具有多个以太网接口的机器上进行操作时,我们如何设置源 IP 地址?

python sockets client tcp-ip server

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

client ×1

functional-programming ×1

list ×1

ocaml ×1

python ×1

server ×1

sockets ×1

tcp-ip ×1