Skip to content

Instantly share code, notes, and snippets.

View carcigenicate's full-sized avatar

Brendon Williams carcigenicate

View GitHub Profile
// 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
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]
<html>
<head>
<style>
img {
position: absolute;
}
div {
position: absolute;
width: 500px;
height: 500px;
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]))
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`:
; 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})
(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]
[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]
(reduce (fn [sum n]
(println sum n)
(+ sum n))
0
[1 2 3 4 5])
; Prints
0 1
1 2
3 3
def fnc ():
baseurls = lst() # Added an s to the name because there's multiple
for baseurl in baseurls # Then grab each url
request = requests.get(baseurl)
response = str(request.content)
page_soup = BeautifulSoup(response, 'html.parser')
a = page_soup.findAll("div",{"class":"large-7 medium-9 columns"})
b = page_soup.findAll("div",{"body field"})