[Fluxus] Apropos, Printing matrices and a little syntactic sugar
Scott
alcoholiday at gmail.com
Tue Mar 10 18:41:26 PDT 2009
Hey folks - I don't know if anyone is interested, but I've implemented
the following functions and am happy to share.
Since I'm trying to learn/remember scheme programming and discovering
all the different libraries out there, including libfluxus I find
apropos to be REALLY HELPFUL.
; apropos - Searches the global symbol table for symbols containing
the string passed to it
> (apropos "format")
("format" "pretty-format")
; pmat and pvec - pretty print matrices and vectors .
> (define m (mtranslate (vector 1 2 3)))
> (pmat m)
1.000 0.000 0.000 0.000
0.000 1.000 0.000 0.000
0.000 0.000 1.000 0.000
1.000 2.000 3.000 1.000
> (pvec (vector 1 2 (sin 3)))
1.000 2.000 0.141
; non vector forms of (m)rotate and (m)translate
> (pmat (mrotate 0 180 0))
-1.000 0.000 0.000 0.000
0.000 1.000 0.000 0.000
-0.000 0.000 -1.000 0.000
0.000 0.000 0.000 1.000
; same results as:
>(pmat (mrotate (vector 0 180 0)))
-1.000 0.000 0.000 0.000
0.000 1.000 0.000 0.000
-0.000 0.000 -1.000 0.000
0.000 0.000 0.000 1.000
--
Here's the code that implements apropos... I'm thinking it might be
cool to link it in with fluxus documentation functions too.
;; apropos
(define apropos-regex #f)
(let ((apropos-list (map symbol->string (namespace-mapped-symbols))))
(set! apropos-regex (lambda (s)
(let ((al (filter (lambda (l) (regexp-match s l)) apropos-list)))
al))))
(define (apropos s)
(apropos-regex (string-append ".*" s ".*")))
-Scott
More information about the Fluxus
mailing list