Skip to content

Instantly share code, notes, and snippets.

@rebcabin
Forked from zacque0/if.lisp
Created July 18, 2025 00:24
Show Gist options
  • Save rebcabin/e36d2ee3cb7e98a2ab233660c5e975c8 to your computer and use it in GitHub Desktop.
Save rebcabin/e36d2ee3cb7e98a2ab233660c5e975c8 to your computer and use it in GitHub Desktop.
"IF-" by RUDYARD KIPLING
;; My comment to https://old.reddit.com/r/lisp/comments/1m1bezg/kiplings_if_art_poetry_and_lisp_a_challenge/
(defpackage "IF- by RUDYARD KIPLING"
(:use "CL"))
(in-package "IF- by RUDYARD KIPLING")
(defvar *you*)
(defmacro *you* (&body body)
t)
(defmacro but (&rest args)
`(and ,@args))
(defmacro all (&rest args)
'(lambda (&rest args2) t))
(defmacro everyone (binder &body body)
`(forall (,binder Human) ,@body))
(defmacro forall (&body body)
t)
(defmacro % (body subordinate &rest rest-body)
"Grammatical device for reordering"
(append subordinate (list* body rest-body)))
(defmacro knaves (&body body)
t)
(defmacro except (&rest body)
`(and ,@body))
(defmacro can-hurt (&rest body)
nil)
(defun if- ()
(if (and
;; First stanza
(% (*you* keep head)
(when (and (funcall (all about *you*) 'losing 'theirs)
(funcall (all about *you*) 'blaming 'it 'on 'you))))
(% (*you* trust yourself)
(when (everyone (x) (doubt x *you*)))
(but (*you* allow doubt)))
(and (*you* can wait) (*you* are not tired by waiting))
(when (*you* are being lied about) (*you* don't deal in lies))
(when (*you* are being hated) (*you* don't give way to hating))
(or (*you* don't look to good) (*you* don't talk too wise))
;; Second stanza
(and (*you* can dream) (*you* don't not make dreams your master))
(and (*you* can think) (*you* don't not make thoughts your aim))
(and (*you* can meet with (and +Triumph+ +Disaster+))
(*you* treat two impostors just the same))
(% (*you* can bear to hear the truth you've spoken)
(when (knaves (twisted truth) to (trap fools))))
(when (*you* watch the things you gave your life to broken)
(*you* stoop)
(*you* build 'em up with worn-out tools))
;; Third stanza
(when (and (*you* can make one heap of all your winnings)
(*you* risk it on one turn of pitch-and-toss)
(*you* lose) (*you* start again at your beginnings))
(*you* never breathe a word about your loss))
(*you* can force (your +heart+ +nerve+ +sinew+)
(to serve (your turn) long after they are gone))
(% (*you* hold on)
(when (*you* have nothing left in *you*))
(except (*you* have the +Will+)
(*you* prin1 "Hold on!")))
;; Fourth stanza
(and (*you* can talk with crowds) (*you* keep your virtue))
(and (*you* walk with Kings) (*you* not lose the common touch))
(and (not (can-hurt foes *you*))
(not (can-hurt loving-friends *you*)))
(everyone (x) (and (counts-with-you x)
(not (too-much-influence x))))
(*you* fill unforgiving minute with distance run (unit 60 seconds)))
;; then
(and (*you* have (and +Earth+ (everything in +Earth+)))
(*you* will be a +Man+)
(setf *you* '|My son!|)))) ; => |My son!|
;; Execute
(if-)
(format t "*you*: ~A~%" *you*)
$ sbcl --script if.lisp
*you*: My son!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment