Skip to content

Instantly share code, notes, and snippets.

@fmap
Created April 8, 2015 09:20
Show Gist options
  • Save fmap/01da66fd8dba94afd4bc to your computer and use it in GitHub Desktop.
Save fmap/01da66fd8dba94afd4bc to your computer and use it in GitHub Desktop.
let
inherit (builtins) map;
inherit ((import <nixpkgs> {}).lib)
fold hasSuffix stringToCharacters concatStrings any;
in rec {
inits = fold (x: y: [[]] ++ map (z: [x] ++ z) y) [[]];
hasInfix = i: str: any (x: hasSuffix i (concatStrings x)) (inits (stringToCharacters str));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment