Paste number 70716: genetic programming

Index of paste annotations: 1

Paste number 70716: genetic programming
Pasted by: blarf
When:7 months, 2 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1IKC
Channel:None
Paste contents:
Raw Source | XML | Display As
(defn fitness [coll-f goal val]
  (reduce #(if (proximity goal (%1 val) (%2 val))
	     %1
	     %2
	     ) coll-f))

(defmacro rand-func [vars]
  (for [x (range (count vars))]
    `(list ( fn [ ~(first vars) ] 
		(* ~(first vars) ~(first vars) ) ) )))

(defmacro rand-func [vars]
  `(list ( fn [ ~(first vars) ] 
	      (* ~(first vars) 
		 ~(first vars) ) ) ))

(defmacro rand-func [vars]
  (let [f 
	`(list ( fn [ ~(first vars) ]
		    (* ~(first vars) 
		       ~(first vars) ) ) )]
    (struct fun f (list f))))

(defstruct fun :f :rep)



user=> #'user/fun
user=> nil
user=> (rand-func [x])
java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
	at user.eval__2750.invoke(Unknown Source)
	at clojure.lang.Compiler.eval(Compiler.java:3891)
	at clojure.lang.Repl.main(Repl.java:75)
user=> 

Annotations for this paste:

Annotation number 1: as
Pasted by: blarf
When:7 months, 2 weeks ago
Share:Tweet this! | http://paste.lisp.org/+1IKC#1
Paste contents:
Raw Source | Display As
user=> (rand-func ['x])
java.lang.Exception: Unsupported binding form: clojure.lang.PersistentList@e8c11342
cl

Colorize as:
Show Line Numbers
Index of paste annotations: 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.