C'è un modo per nidificare chiamate a modelli attivi?C'è un modo per nidificare le chiamate ai pattern attivi di F #?
Qualcosa di simile a questo:
type Fnord =
| Foo of int
let (|IsThree|IsNotThree|) x =
match x with
| x when x = 3 -> IsThree
| _ -> IsNotThree
let q n =
match n with
| Foo x ->
match x with
| IsThree -> true
| IsNotThree -> false
// Is there a more ideomatic way to write the previous
// 5 lines? Something like:
// match n with
// | IsThree(Foo x) -> true
// | IsNotThree(Foo x) -> false
let r = q (Foo 3) // want this to be false
let s = q (Foo 4) // want this to be true
O è l'incontro seguito da un altro incontro il modo migliore per andare?
+1 per il Fnord. – bmargulies
Il maledetto linguaggio è illeggibile. Seriamente - cosa può fare che Python non può? –
@lpthnc: Pattern matching? – Chuck