How do you work with a List of Records in F#? How would you even pass that as an argument in a function? I want to do something like this:
type Car = {
Color : string;
Make : string;
}
let getRedCars cars =
List.filter (fun x -> x.Color = "red") cars;
let car1 = { Color = "red"; Make = "Toyota"; }
let car2 = { Color = "black"; Make = "Ford"; }
let cars = [ car1; car2; ]
I need a way to tell my function that "cars" is a List of Car records.
car1
andcar2
declarations not being oftype Car
- so it cannot automatically determine the type signature. – PulquegetRedCars
isCar list -> Car list
. What errors are you seeing? – Piscary;
at the end of the body ofgetRedCars
is valid. Using verbose syntax I would except only;;
for a top-level declaration, or ` in ... ` for a local expression. – Felike