Skip to content

Instantly share code, notes, and snippets.

View mathieueveillard's full-sized avatar

Mathieu Eveillard mathieueveillard

View GitHub Profile
/*
* 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)),
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();
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);
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)) {

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”.