Skip to content

Instantly share code, notes, and snippets.

@katsaii
Created March 15, 2021 04:12
Show Gist options
  • Save katsaii/78f590f08f2c1060acaf26727d2419dc to your computer and use it in GitHub Desktop.
Save katsaii/78f590f08f2c1060acaf26727d2419dc to your computer and use it in GitHub Desktop.
Splits a name and displays all possible splits, prefixes and suffixes.
fst((A, _), A).
snd((_, B), B).
name("katsaii").
?-
name(Name),
findall((Prefix, Suffix), string_concat(Prefix, Suffix, Name), Pairs),
maplist(fst, Pairs, Prefixes),
maplist(snd, Pairs, Suffixes),
write("pairs: "), write(Pairs), nl,
write("prefixes: "), write(Prefixes), nl,
write("suffixes: "), write(Suffixes).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment