F# 执行命令
我是F#的新手,所以这段代码对我来说很奇怪F# 执行命令,f#,F#,我是F#的新手,所以这段代码对我来说很奇怪 let randomTest avgWait avgBusyTime numExp numClients labsRules = let clients, _ = mkClientsAndLabs numClients labsRules doTest [for i in 0..numClients-1 -> randomTestClient clients i avgWait avgBusyTime numExp ] do
let randomTest avgWait avgBusyTime numExp numClients labsRules =
let clients, _ = mkClientsAndLabs numClients labsRules
doTest [for i in 0..numClients-1 -> randomTestClient clients i avgWait avgBusyTime numExp ]
do let clients, _ = mkClientsAndLabs 5 [rulesA; rulesB]
doTest [scheduledClient clients 0 [(0, 500, A)]; // Request a lab at the very start, use for "A" for 0.5 seconds
scheduledClient clients 1 [(200, 300, Mix (Mix (A,Mix (A,A)),B))] ; // Request after 0.2s, release 0.3s later.
scheduledClient clients 2 [(300, 200, Mix (A,Mix (A,A)))]; // These three will all be waiting for a lab.
scheduledClient clients 3 [(400, 200, Mix (A,A))]; // Client 2 should include the others as guests.
scheduledClient clients 4 [(400, 200, A)]
]
我不确定的是
dolet
声明-它显然是在randomTest
之后声明的,但是randomTest
仍然可以调用该函数。这段代码的执行顺序是什么?它的编写方式可能令人困惑。没有所谓的do-let
声明。
实际上,它是一个完整的do{code}
块,在{code}
中有一个let绑定。
这意味着它不是函数声明,do块只是要执行的代码,它不声明函数或值
这样应该更容易阅读:
do
let clients, _ = mkClientsAndLabs 5 [rulesA; rulesB]
doTest [scheduledClient clients 0 [(0, 500, A)]; // Request a lab at the very start, use for "A" for 0.5 seconds
scheduledClient clients 1 [(200, 300, Mix (Mix (A,Mix (A,A)),B))] ; // Request after 0.2s, release 0.3s later.
scheduledClient clients 2 [(300, 200, Mix (A,Mix (A,A)))]; // These three will all be waiting for a lab.
scheduledClient clients 3 [(400, 200, Mix (A,A))]; // Client 2 should include the others as guests.
scheduledClient clients 4 [(400, 200, A)]
]
因此,执行顺序首先是让随机测试…,然后是
do
块。它的编写方式可能令人困惑。没有所谓的do-let
声明。
实际上,它是一个完整的do{code}
块,在{code}
中有一个let绑定。
这意味着它不是函数声明,do块只是要执行的代码,它不声明函数或值
这样应该更容易阅读:
do
let clients, _ = mkClientsAndLabs 5 [rulesA; rulesB]
doTest [scheduledClient clients 0 [(0, 500, A)]; // Request a lab at the very start, use for "A" for 0.5 seconds
scheduledClient clients 1 [(200, 300, Mix (Mix (A,Mix (A,A)),B))] ; // Request after 0.2s, release 0.3s later.
scheduledClient clients 2 [(300, 200, Mix (A,Mix (A,A)))]; // These three will all be waiting for a lab.
scheduledClient clients 3 [(400, 200, Mix (A,A))]; // Client 2 should include the others as guests.
scheduledClient clients 4 [(400, 200, A)]
]
因此,执行顺序首先是让随机测试…,然后是
do
块。它的编写方式可能令人困惑。没有所谓的do-let
声明。
实际上,它是一个完整的do{code}
块,在{code}
中有一个let绑定。
这意味着它不是函数声明,do块只是要执行的代码,它不声明函数或值
这样应该更容易阅读:
do
let clients, _ = mkClientsAndLabs 5 [rulesA; rulesB]
doTest [scheduledClient clients 0 [(0, 500, A)]; // Request a lab at the very start, use for "A" for 0.5 seconds
scheduledClient clients 1 [(200, 300, Mix (Mix (A,Mix (A,A)),B))] ; // Request after 0.2s, release 0.3s later.
scheduledClient clients 2 [(300, 200, Mix (A,Mix (A,A)))]; // These three will all be waiting for a lab.
scheduledClient clients 3 [(400, 200, Mix (A,A))]; // Client 2 should include the others as guests.
scheduledClient clients 4 [(400, 200, A)]
]
因此,执行顺序首先是让随机测试…,然后是
do
块。它的编写方式可能令人困惑。没有所谓的do-let
声明。
实际上,它是一个完整的do{code}
块,在{code}
中有一个let绑定。
这意味着它不是函数声明,do块只是要执行的代码,它不声明函数或值
这样应该更容易阅读:
do
let clients, _ = mkClientsAndLabs 5 [rulesA; rulesB]
doTest [scheduledClient clients 0 [(0, 500, A)]; // Request a lab at the very start, use for "A" for 0.5 seconds
scheduledClient clients 1 [(200, 300, Mix (Mix (A,Mix (A,A)),B))] ; // Request after 0.2s, release 0.3s later.
scheduledClient clients 2 [(300, 200, Mix (A,Mix (A,A)))]; // These three will all be waiting for a lab.
scheduledClient clients 3 [(400, 200, Mix (A,A))]; // Client 2 should include the others as guests.
scheduledClient clients 4 [(400, 200, A)]
]
所以执行顺序首先是代码>让随机化测试…<代码>,然后<代码> do/c>块。< /p>如果有任何答案解决了您的问题,请通过点击复选标记来考虑。这向更广泛的社区表明,你已经找到了一个解决方案,并给回答者和你自己带来了一些声誉。没有义务这样做。如果有任何答案解决了你的问题,请考虑点击复选标记。这向更广泛的社区表明,你已经找到了一个解决方案,并给回答者和你自己带来了一些声誉。没有义务这样做。如果有任何答案解决了你的问题,请考虑点击复选标记。这向更广泛的社区表明,你已经找到了一个解决方案,并给回答者和你自己带来了一些声誉。没有义务这样做。如果有任何答案解决了你的问题,请考虑点击复选标记。这向更广泛的社区表明,你已经找到了一个解决方案,并给回答者和你自己带来了一些声誉。没有义务这样做。