We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1289bff commit 2a9b303Copy full SHA for 2a9b303
1 file changed
_snippets/sequence_expressions.md
@@ -3,14 +3,11 @@ order: 15
3
title: SequenceExpressions.fs
4
excerpt_separator: <!--more-->
5
code: |
6
- // This is an active pattern. It allows customized pattern matching.
7
- let (|Divides|_|) divisor x = x % divisor = 0
8
let rec fizzBuzzSeq n = seq {
9
- match n with
10
- | Divides 15 -> "fizzbuzz"
11
- | Divides 3 -> "fizz"
12
- | Divides 5 -> "buzz"
13
- | _ -> n.ToString()
+ if n % 15 = 0 then "fizzbuzz"
+ elif n % 3 = 0 then "fizz"
+ elif n % 5 = 0 then "buzz"
+ else n.ToString()
14
15
// Tail recursion makes this as efficient as a "while" loop
16
yield! fizzBuzzSeq (n + 1)
0 commit comments