Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This code snippet is an extract of a private codebase. Though it relies on many dependencies to | |
* the rest of the codebase, I believe that the code carries enough intension so that one can get | |
* the overall idea (see: https://blog.mathieueveillard.com/monkey-testing-et-property-based-testing-une-exploration) | |
*/ | |
import fc from "fast-check"; | |
const ALL_REDUCERS: HasName<Reducer<ApplicationState>>[] = [ | |
withName("selectPhotograph")(pickRandomIndex(getNumberOfPhotographs)(selectionReducers.selectPhotograph)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createMock = <T>(values: T[] = []) => { | |
function* generator(): Generator<T, T | undefined, T> { | |
for (let i = 0; i < values.length; i++) { | |
yield values[i]; | |
} | |
return undefined; | |
} | |
const generatorInstance = generator(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const IdentityFunctor = <S>(value: S) => { | |
return { | |
map: <U>(fn: (s: S) => U) => IdentityFunctor(fn(value)), | |
valueOf: () => value, | |
}; | |
}; | |
const appendIfMultipleOf = (stringToAppend: string) => (m: number) => (n: number) => (s: string): string => { | |
if (n % m === 0) { | |
return (s += stringToAppend); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isMultipleOf = (m: number) => (n: number): boolean => n % m === 0; | |
export function internal(n: number): string { | |
let result = ""; | |
if (isMultipleOf(3)(n)) { | |
result += "Fizz"; | |
} | |
if (isMultipleOf(5)(n)) { |