Skip to content

Commit 2a9b303

Browse files
authored
Focus on the seq expression
1 parent 1289bff commit 2a9b303

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

_snippets/sequence_expressions.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ order: 15
33
title: SequenceExpressions.fs
44
excerpt_separator: <!--more-->
55
code: |
6-
// This is an active pattern. It allows customized pattern matching.
7-
let (|Divides|_|) divisor x = x % divisor = 0
86
let rec fizzBuzzSeq n = seq {
9-
match n with
10-
| Divides 15 -> "fizzbuzz"
11-
| Divides 3 -> "fizz"
12-
| Divides 5 -> "buzz"
13-
| _ -> n.ToString()
7+
if n % 15 = 0 then "fizzbuzz"
8+
elif n % 3 = 0 then "fizz"
9+
elif n % 5 = 0 then "buzz"
10+
else n.ToString()
1411
1512
// Tail recursion makes this as efficient as a "while" loop
1613
yield! fizzBuzzSeq (n + 1)

0 commit comments

Comments
 (0)