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
| (defn breed [parent-a parent-b] | |
| (let [breed-index (rand (count parent-a)) | |
| transmission-a (take breed-index parent-a) | |
| transmission-b (drop breed-index parent-b) | |
| pure-child (concat transmission-a transmission-b)] | |
| mutate-agent pure-child)) |
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
| {"mobileview":{"sections":[{"id":0,"text":""},{"toclevel":1,"line":"English","id":1,"text":"<h2><span class=\"mw-headline\" id=\"English\">English<\/span><\/h2>\n<div class=\"sister-wikipedia sister-project noprint floatright\" style=\"border: 1px solid #aaa; font-size: 90%; background: #f9f9f9; width: 250px; padding: 4px; text-align: left;\">\n<div style=\"float: left;\">\n<div class=\"floatnone\"><span class=\"mw-mf-image-replacement\">[Image]<\/span><\/div>\n<\/div>\n<div style=\"margin-left: 60px;\"><a href=\"\/wiki\/Wikipedia\" title=\"Wikipedia\">Wikipedia<\/a> has an article on:\n<div style=\"margin-left: 10px;\"><b class=\"Latn\" lang=\"en\" xml:lang=\"en\"><a href=\"\/\/en.wikipedia.org\/wiki\/This\" class=\"extiw\" title=\"w:This\">This<\/a><\/b><\/div>\n<\/div>\n<\/div>\n<p><span class=\"interProject\"><a href=\"\/\/en.wikipedia.org\/wiki\/This\" class=\"extiw\" title=\"w:This\">Wikipedia<\/a><\/span><\/p>"},{"toclevel":2,"line":"Etymology","id":2,"text":"<h3><span class=\"mw-headline\" id=\"Etymol |
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
| clojoomba.core.runner=> (time (count (nth (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200}) 2))) | |
| "Elapsed time: 133.896 msecs" | |
| 20 | |
| clojoomba.core.runner=> (time (count (nth (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200}) 2))) | |
| "Elapsed time: 121.748 msecs" | |
| 20 | |
| clojoomba.core.runner=> (time (count (nth (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200}) 2))) | |
| "Elapsed time: 113.795 msecs" | |
| 20 | |
| clojoomba.core.runner=> (time (count (last (take 2 (clojoomba.core.evolution/evolutions {:agents (gen-agents 20) :room-size 10 :num-rooms 10 :steps 200}))))) |
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
| class Foo { | |
| val emailer: EmailService | |
| } | |
| trait Fakes { | |
| val emailer = new FakeEmailService() | |
| } | |
| trait RealThings { | |
| val emailer = new SmtpEmailService() |
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
| ;not sure why this doesn't really memoize the anonymous function call | |
| (defn add [a b] ((memoize (fn [x y] (Thread/sleep 1000) (+ x y))) a b)) | |
| ;this does correctly memoize the (non anonymous) function call | |
| (defn adds [a b] (Thread/sleep 1000) (+ a b)) | |
| (def addf (memoize adds)) |
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
| (defn basic-item-total [price quantity] | |
| (* price quantity)) | |
| (defn with-line-item-conditions [f price quantity] | |
| (apply f price quantity)) |
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
| class Parent | |
| class << self | |
| alias_method :orig_new, :new | |
| def new(arg) | |
| puts "newing parent with #{arg}" | |
| orig_new | |
| end | |
| end |
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
| object Hulu { | |
| def playVideo(video: Content) { | |
| try { | |
| video.streamToTV() | |
| } catch { | |
| case t:Throwable => playNextAd() | |
| } | |
| } | |
| } |
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
| something = if x > 10 | |
| 'hello' | |
| else | |
| 'bye' | |
| end |
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
| numb = 10 | |
| while numb != 0 | |
| bottle = "bottle" | |
| if numb > 1 | |
| bottle = "bottles" | |
| end | |
| puts numb.to_s + ' ' + bottle + ' of beer on the wall ' + numb.to_s + ' ' + bottle +' of beer' |