solutions/A Tour of Nix/30.nix

10 lines
305 B
Nix
Raw Normal View History

2024-04-16 19:13:00 -04:00
with import <nixpkgs> { };
let
listOfNumbers = [2 4 6 9 27];
myMap = f: l: lib.fold (x: y: [(f x)] ++ y) [] l;
in
rec {
#your map should create the same result as the standard map function
example = map (x: builtins.div x 2) listOfNumbers;
result = myMap (x: builtins.div x 2) listOfNumbers;
}