1//
2// immer: immutable data structures for C++
3// Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente
4//
5// This software is distributed under the Boost Software License, Version 1.0.
6// See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt
7//
8
9#include <immer/vector.hpp>
10#include <string>
11#include <iostream>
12
13// include:fizzbuzz/start
14immer::vector<std::string> fizzbuzz(immer::vector<std::string> v, int first, int last)
15{
16 for (auto i = first; i < last; ++i)
17 v = std::move(v).push_back(
18 i % 15 == 0 ? "FizzBuzz" :
19 i % 5 == 0 ? "Bizz" :
20 i % 3 == 0 ? "Fizz" :
21 /* else */ std::to_string(i));
22 return v;
23}
24// include:fizzbuzz/end
25
26int main()
27{
28 auto v = fizzbuzz({}, 0, 100);
29 std::copy(v.begin(), v.end(),
30 std::ostream_iterator<std::string>{
31 std::cout, "\n"});
32}
33