Flo: Unterschied zwischen den Versionen

aus dem Wiki des Entropia e.V., CCC Karlsruhe
((SCREW LISP))
(Yeah! Lecker Extended-Loop-Macro! Und die einzelnen Flo-Variablen werden zur Kompilierzeit erstellt!)
Zeile 14: Zeile 14:


<pre>
<pre>
(defvar *flo* #("dividuum" "syb" "fiji" "flowhase"))
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defvar *flo-sequence* #("dividuum" "syb" "fiji" "flowhase")))
 
(defmacro make-individual-flo-variables ()
  (cons 'progn
        (loop for flo across *flo-sequence*
              for i from 0
              collect `(defvar ,(read-from-string (format nil "*flo~d*" i)) ,flo))))
 
(make-individual-flo-variables)


(dotimes (i 4)
(dotimes (i 4)
  (format t "~&flo~d = ~a" i (svref *flo* i)))
    (format t "~&flo~d = ~a" i (eval (read-from-string (format nil "*flo~d*" i)))))
</pre>  
</pre>  


[[Kategorie:Wissen]]
[[Kategorie:Wissen]]
[[Kategorie:Entropia]]
[[Kategorie:Entropia]]

Version vom 1. November 2005, 18:33 Uhr

#!/usr/bin/env ruby

flo = [ "dividuum", "syb", "fiji", "flowhase" ]

# flos sind keine arrayss1!
for i in 0..3
  eval "flo#{i} = flo[#{i}]"
  puts "flo#{i} == \"" + eval("flo#{i}") + "\""
end

Dieses Perl (*duck*) kann ja keiner lesen!

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defvar *flo-sequence* #("dividuum" "syb" "fiji" "flowhase")))

(defmacro make-individual-flo-variables ()
  (cons 'progn
        (loop for flo across *flo-sequence*
              for i from 0
              collect `(defvar ,(read-from-string (format nil "*flo~d*" i)) ,flo))))

(make-individual-flo-variables)

(dotimes (i 4)
    (format t "~&flo~d = ~a" i (eval (read-from-string (format nil "*flo~d*" i)))))