小编Bad*_*sef的帖子

F#中的高阶函数

大家好我想表达函数调用test1而不首先定义更高的函数

let higher = fun a b -> a>b
let rec test1 test2 number list=

        match (number,list) with
        |number,[]                           -> []
        |number,x1::xs when test2 a x = true -> x1::test1 test2 number xs 
        |number,x1::xs                       -> test1 test2 number xs 

printfn "%A" (test1 (higher 5 [5;2;7;8]))
Run Code Online (Sandbox Code Playgroud)

lambda f# functional-programming

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

如何将字符串转换为F#中的列表单词

我需要将一个字符串转换为一个没有内置函数的单词列表,这是我到目前为止所做的,显然是错误的:

let rec convert word = 
    match word with
    |"."      ->[]
    |word -> ["word"]
    |word + " " + words -> [word]@convert words
Run Code Online (Sandbox Code Playgroud)

string f# list

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

标签 统计

f# ×2

functional-programming ×1

lambda ×1

list ×1

string ×1