Skip to content

Instantly share code, notes, and snippets.

@pfctdayelise
Last active January 4, 2016 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfctdayelise/8648478 to your computer and use it in GitHub Desktop.
Save pfctdayelise/8648478 to your computer and use it in GitHub Desktop.
% Generate/verify memes in Prolog.
noun(apple).
noun(banana).
noun(orange).
noun(kiwifruit).
irregular_noun(kiwifruit, kiwifruit).
verb(eat).
verb(clean).
verb(buy).
verb(cook).
plural_noun(Sg, Pl):-
irregular_noun(Sg, Pl), !.
plural_noun(Sg, Pl):-
atom_concat(Sg, s, Pl).
% http://knowyourmeme.com/memes/x-all-the-y
x_all_the_ys(Str):-
noun(Noun),
plural_noun(Noun, Pluralnoun),
atom_concat(Pluralnoun, '!', Ys),
verb(Verb),
[Verb, all, the, Ys] = Words,
atomic_list_concat(Words, ' ', Str).
% http://knowyourmeme.com/memes/xzibit-yo-dawg
yo_dawg(Str):-
noun(Noun),
plural_noun(Noun, Pluralnoun),
[so, i, put, Pluralnoun, in, your, Pluralnoun] = Rest,
[yo, dawg, i, heard, you, like, Pluralnoun|Rest] = Words,
atomic_list_concat(Words, ' ', Str).
yo_dawg(Str):-
verb(Verb),
noun(Noun),
plural_noun(Noun, Pluralnoun),
[so, you, can, Verb, while, you, Verb] = Rest2,
[so, i, put, Pluralnoun, in, your, Pluralnoun|Rest2] = Rest,
[yo, dawg, i, heard, you, like, Pluralnoun|Rest] = Words,
atomic_list_concat(Words, ' ', Str).
meme(x_all_the_ys).
meme(yo_dawg).
ismeme(S):-
meme(Pred),
call(Pred, S).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment