This file contains 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
class FStore | |
attr_accessor :dynamic_methods | |
def initialize | |
@dynamic_methods = [] | |
end | |
def mix(s1, s2, s3, &block) | |
name = "#{s1.to_s}_#{s2.to_s}_#{s3.to_s}".to_sym | |
self.send(name) {|a,b| send(s1, send(s2,a), send(s3,b))} | |
end | |
def method_missing(symbol, &block) |
This file contains 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
(defn list-crossover | |
"A generic crossover function for simple lists. You may need to write your own." | |
[[s1 s2]] | |
(let [point (rand-int | |
(min (count s1) | |
(count s2)))] | |
(concat (take point s1) | |
(drop point s2)))) |
This file contains 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
int add_files_to_cache(const char *prefix, const char **pathspec, int flags) | |
{ | |
struct update_callback_data data; | |
struct rev_info rev; | |
init_revisions(&rev, prefix); | |
setup_revisions(0, NULL, &rev, NULL); | |
rev.prune_data = pathspec; | |
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; | |
rev.diffopt.format_callback = update_callback; | |
data.flags = flags; |
This file contains 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
(defn run-ga | |
[func-map setting-map] | |
(let [ipop ((:init-fn func-map) (:pop-sz setting-map))] | |
(loop [pop ipop | |
num (:gen setting-map)] | |
(if (zero? num) | |
(do | |
(println (first (sort-by (:fit-fn func-map) > pop )))) | |
(let [total-left (- (:pop-sz setting-map) | |
(:children setting-map))] |
This file contains 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
(defn graph-words [url nums nume step] | |
(let [raw (sortmap (count-words url)) | |
rng (range nums (+ nume 1) step) | |
totake (/ 10 (length rng)) | |
data (map #(interesting raw %1 totake) rng) | |
words (map #(map (fn [x] (first x)) %1) data) | |
numbers (map #(map (fn [x] (second x)) %1) data) | |
bigwords (reduce concat words) | |
bignums (reduce concat numbers) | |
size (length (first words)) |
This file contains 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
(defn rec-map [lst] | |
(if (sequential? lst) | |
(map #(if (map? %1) | |
(let [mytag (str (%1 :tag)) | |
con (%1 :content) | |
domatch (match mytag [":div" ":html" ":p" ":body"]) | |
newc (if domatch con "")] | |
(trampoline rec-map newc)) | |
(if (sequential? %1) | |
(trampoline rec-map %1) |
NewerOlder