### Eric Florenzano’s Programming Meme in Prolog

I was pointed to Eric Florenzano’s Programming Meme today. I decided to take up the challenge with a language I’ve always wanted to learn: Prolog!

A few hours later, and I got something that works. I can’t say it’s at all elegant, but it’s late and at this point I’m just happy I figured out the language’s I/O. Any pointers on Prolog are welcome.

Without further ado, here’s the meme:

Rules:

1. Implement a program that takes in a user’s name and their age, and prints hello to them once for every year that they have been alive.
2. Post these rules, the source code for your solution, and the following list (with you included) on your blog.
3. Bonus points if you implement it in a language not yet seen on the following list!

The List:

The Prolog solution:

```getout(Name,0,[]).

getout(Name,N,Output) :-
N > 0,
N1 is N-1,
Output = [[N, ') Hello, ', Name, '\n'] | Output1],
getout(Name,N1,Output1).

doit :-
write('What is your name? Remember to put a period after it, and put it in quotes if there are spaces.'), nl,
write('How old are you?  You\'re going to want to enter a number then a period here.'), nl,
getout(Name,Age,W  ),
reverse(W,X),
append(X,Z),
concat_atom(Z, Out),
write(Out).
```

Here’s an example of running it with SWI-Prolog:

```?- ['meme.pro'].
Warning: /home/sb/meme.pro:2:
Singleton variables: [Name]
% meme.pro compiled 0.00 sec, 8 bytes
true.

?- doit.
What is your name? Remember to put a period after it, and put it in quotes if there are spaces.
|    'Sebastian Benthall'.
How old are you?  You're going to want to enter a number then a period here.
|    24.
1) Hello, Sebastian Benthall
2) Hello, Sebastian Benthall
3) Hello, Sebastian Benthall
4) Hello, Sebastian Benthall
5) Hello, Sebastian Benthall
6) Hello, Sebastian Benthall
7) Hello, Sebastian Benthall
8) Hello, Sebastian Benthall
9) Hello, Sebastian Benthall
10) Hello, Sebastian Benthall
11) Hello, Sebastian Benthall
12) Hello, Sebastian Benthall
13) Hello, Sebastian Benthall
14) Hello, Sebastian Benthall
15) Hello, Sebastian Benthall
16) Hello, Sebastian Benthall
17) Hello, Sebastian Benthall
18) Hello, Sebastian Benthall
19) Hello, Sebastian Benthall
20) Hello, Sebastian Benthall
21) Hello, Sebastian Benthall
22) Hello, Sebastian Benthall
23) Hello, Sebastian Benthall
24) Hello, Sebastian Benthall
```