Skip to content

Instantly share code, notes, and snippets.

@cametan001
Created May 8, 2010 01:07
Show Gist options
  • Save cametan001/394211 to your computer and use it in GitHub Desktop.
Save cametan001/394211 to your computer and use it in GitHub Desktop.
CL-USER> (print-name-of-function "Fuck off!!!")
FUCK-OFF
CL-USER> (fuck-off)
Fuck off!!!
"Fuck off!!!"
CL-USER>
(defpackage :print-name-of-function-system (:use :asdf :cl))
(in-package :print-name-of-function-system)
(defsystem p-n-f
:name "p-n-f"
:author ""
:version ""
:maintainer ""
:licence ""
:description ""
:long-description ""
:components
((:file "packages")
(:file "print-name-of-function" :depends-on ("packages"))))
(in-package :cl-user)
(defpackage :p-n-f
(:use :common-lisp)
(:export :print-name-of-function))
(in-package #:p-n-f)
(defmacro print-name-of-function (str)
(let ((name (map 'string #'(lambda (x)
(if (string= x " ")
#\-
x))
(remove-if-not #'(lambda (x)
(or (string= x " ")
(and (string<= "A" x)
(string<= x "Z"))))
(string-upcase str)))))
`(defun ,(intern name) ()
(princ ,str))))
; loading system definition from /home/cametan/p-n-f.asd into
; #<PACKAGE "ASDF0">
; registering #<SYSTEM P-N-F {B3F2391}> as P-N-F
CL-USER> (use-package :p-n-f)
T
CL-USER> (macroexpand-1 '(print-name-of-function "Hello, World!"))
(DEFUN HELLO-WORLD () (PRINC "Hello, World!"))
T
CL-USER> (print-name-of-function "Hello, World!")
HELLO-WORLD
CL-USER> (hello-world)
Hello, World!
"Hello, World!"
CL-USER> (symbol-package 'hello-world)
#<PACKAGE "COMMON-LISP-USER">
CL-USER> (symbol-function 'hello-world)
#<FUNCTION HELLO-WORLD>
CL-USER> (symbol-package 'print-name-of-function)
#<PACKAGE "P-N-F">
CL-USER>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment