Created
May 8, 2010 01:07
-
-
Save cametan001/394211 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CL-USER> (print-name-of-function "Fuck off!!!") | |
FUCK-OFF | |
CL-USER> (fuck-off) | |
Fuck off!!! | |
"Fuck off!!!" | |
CL-USER> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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")))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(in-package :cl-user) | |
(defpackage :p-n-f | |
(:use :common-lisp) | |
(:export :print-name-of-function)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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