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
factorial = { 1 } | |
setmetatable(factorial, { __index = function(table, key) | |
table[key] = table[key - 1] * key | |
return table[key] | |
end, __call = function(table, n) | |
for i = 1, n do | |
print(table[i]) | |
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
private ExpectedCondition<Boolean> element(final By findCondition) { | |
return new ExpectedCondition<Boolean>() { | |
@Override | |
public Boolean apply(WebDriver from) { | |
RenderedWebElement element = (RenderedWebElement) | |
driver.findElement(findCondition); | |
return element.isDisplayed(); | |
} | |
}; | |
} |
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 char-counter [str] | |
(reduce | |
(fn [m c] | |
(assoc m c (inc (get m c 0)))) | |
{} | |
str)) |
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
val n: Option[Int] = None | |
val res = n.map(_ + 4).map(_ + 100) | |
res.getOrElse(0) // => 0 | |
val n: Option[Int] = Some(10) | |
val res = n.map(_ + 4).map(_ + 100) | |
res.getOrElse(0) // => 114 |
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
(letfn [(factorial [n i] | |
(if (> i 1) | |
(factorial | |
(* n i) | |
(dec i)) | |
n))] | |
(factorial 1 5)) |
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
(reduce ; Kootaan yks mappi sanoista. | |
(partial merge-with +) ; Kahdessa mapissa olevien avainten arvot summataan. | |
(map ; Suorittaa alla olevan funktion kaikille tiedostoille ({"foo" 1} {"baz" 10}). | |
#(frequencies ; Frequencies palauttaa mapin esiintymistä {"foo" 1, "bar" 4}. | |
(re-seq #"\w+" (slurp %))) ; Lukee tiedoston ja luo sekvenssin sanoista. | |
files)) ; Lista tiedostoista. |
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
(deftest div-has-content-foo? | |
(is | |
(= (html [:div "foo"]) | |
"<div>foo</div>"))) |
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
function dispatch(t) | |
return function(k) | |
if t[k] then t[k]() end | |
end | |
end | |
local dispatcher = dispatch({ f = function() | |
print("f") | |
end, | |
g = function() |
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
(def person {:name "Vesa Marttila" | |
:address {:street "Pursimiehenkatu 21"}}) | |
(update-in person | |
[:address] | |
merge {:postal-code "00150" :city "Helsinki"}) | |
; -> {:name "Vesa Marttila", :address {:city "Helsinki", :postal-code "00150", :street "Pursimiehenkatu 13"}} |
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
(-> (query #(SQLQueryImpl. | |
connection | |
(Configuration. templates) | |
%)) | |
(from :actors) | |
(where (equal? :name "George Clooney") | |
(equal? :age 49)) | |
(list :name :age)))))) |
OlderNewer