user1222538
user1222538

Reputation: 3

F# - Seq.iter (type error)

I have the follow function with multiple inputs

let blackscholes strike assetPrice standarddev riskfreerate days2expiration c_p =

And I would like to Seq.iter it so that it is evaluated for multiple values of assetPrice, while holding everything else constant. I am wondering about the syntax, do I have to create an intermediate version of the function that takes only one argument? i.e.

let blackscholesTemp assetPrice = blackscholes 100. assetPrice 0.2 0.05 60 'c' = 

When I try that way and do

printf "Results:" 
Seq.iter (blackscholesTemp) (seq {0.0..10.0..100.0})

I received the error "Type mismatch. Expecting a float -> unit but given a float -> float The type 'unit' does not match the type 'float'"

Upvotes: 0

Views: 357

Answers (1)

John Palmer
John Palmer

Reputation: 25516

You want to use Seq.map instead of Seq.iter as Seq.map returns a sequence of results whilst Seq.iter doesn't return a list of results

Upvotes: 4

Related Questions