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
// Create a function called "add" | |
function add(num1, num2) { | |
var result = num1 + num2 | |
return result // <----- Returning from the function | |
} | |
var result = add(1, 2) // <----- Called the function. "result" holds a 3 | |
var result2 = add(3, 4) // <----- Called the function again. "result2" holds a 7 |
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
def datornsDrag(self,datorBricka,fåLegalaDrag,fåDatorBräde,görDittDrag,räknaPoäng): | |
möjligaDrag = self.fåLegalaDrag(self.bräde,datorBricka) | |
högstaPoäng = -1 | |
for x, y in möjligaDrag: | |
datorBräde = self.fåDatorBräde(self.bräde) | |
print(self.bräde) | |
self.görDittDrag(datorBräde, datorBricka, x, y) | |
print(self.bräde) | |
print("Done test for" + str(x) + " " + str(y)) | |
poäng = self.räknaPoäng(datorBräde)[datorBricka] |
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
<html> | |
<head> | |
<style> | |
img { | |
position: absolute; | |
} | |
div { | |
position: absolute; | |
width: 500px; | |
height: 500px; |
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
project.clj: | |
(defproject sample "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.8.0"] | |
[seesaw "1.4.5"]] | |
Sample file: | |
(ns seesaw-sample | |
(:require [seesaw.core :as sc])) |
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
I'd break this down step by step. | |
First, the keys of each map seem to be irrelevant, so we can get rid of them by `map`ping `vals` over your data (which I'll call `data`): | |
(map vals data) | |
(([{:ms "A", :s 1, :v 15}] [{:ms "A", :s 2, :v 18}] [{:ms "A", :s 4, :v 19}]) | |
([{:ms "A", :s 1, :v2 5}] [{:ms "A", :s 2, :v2 8}] [{:ms "B", :s 4, :v2 9}])) | |
But that leaves some ugly nested lists. I removed them by using a 2D `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
; k for keyword, f for function | |
(defmacro where [[k f arg]] | |
`(fn [a#] ; Expand to a function | |
; that applies k to the map, then applies f to that result, and the passed arg | |
(~f (~k a#) ~arg))) | |
(filter (where [:id < 2]) | |
[{:id 0} {:id 1} {:id 2} {:id 3} {:id 4} {:id 5}]) | |
; Returns ({:id 0} {:id 1}) |
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
(ns bits.sql-syntax) | |
(def test-db [{:id 1, :name "A"}, | |
{:id 0, :name "B"}, | |
{:id 3, :name "C"}, | |
{:id 2, :name "D"}, | |
{:id 4, :name "E"}]) | |
(defn where [arg-vec] | |
(let [[k f comp-arg] arg-vec] |
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
<!-- Global site tag (gtag.js) - Google Analytics --> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-101748454-1"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', 'UA-101748454-1'); | |
</script> | |
<html> |
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
[0.2773242138364778 0.2803242138364779 0.0067561307901907 0.0097561307901907]Date1.06523069184791E8[1.0 2.0 9.930610010001E12 40.0 5.0 6.0 7.0 8.0 9.0] |
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
(reduce (fn [sum n] | |
(println sum n) | |
(+ sum n)) | |
0 | |
[1 2 3 4 5]) | |
; Prints | |
0 1 | |
1 2 | |
3 3 |
OlderNewer