Oracle of Facts and Logic

Source Code

<!doctype html>
		body { padding: 10px; }
		.qa .q:not(:empty)::before { content: "Q: " }
		.qa .a:not(:empty)::before { content: "A: " }
	eightball("It is certain").
	eightball("It is decidedly so").
	eightball("Without a doubt").
	eightball("Yes, definitely").
	eightball("You may rely on it").
	eightball("As I see it, yes").
	eightball("Most likely").
	eightball("Outlook good").
	eightball("Signs point to yes").
	eightball("Reply hazy try again").
	eightball("Ask again later").
	eightball("Better not tell you now").
	eightball("Cannot predict now").
	eightball("Concentrate and ask again").
	eightball("Don't count on it").
	eightball("My reply is no").
	eightball("My sources say no").
	eightball("Outlook not so good").
	eightball("Very doubtful").

	oracle(Question, Wisdom) :-
		findall(X, eightball(X), All),
		length(All, Len),
		term_hash(Question, Hash),
		date_time(_, M, D, _, _, _),
		Index is (Hash + M*D) mod Len,
		nth0(Index, All, Wisdom).
<h1>Oracle of Facts and Logic</h1>

	<form method="POST" enctype="application/x-www-form-urlencoded">
		<input type="text" name="ask" placeholder="ASK ME ANYTHING"
		style="width: 80ch;" value="<?=X form_value(ask, X) ?>"
		<input type="submit" value="Ask">

	<article class="qa">
		<h3 class="q"><?=Ask form_value(ask, Ask). ?></h3>
		<h3 class="a"><?=Wisdom form_value(ask, Ask), oracle(Ask, Wisdom). ?></h3>


	<h2>Source Code</h2>
	<pre><?=Source current_file(File), read_file_to_string(File, Source, []). ?></pre>


powered by <a href="">php</a>