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
{ | |
"response": [ | |
{"title": "Olurum sana", "artists": ["tarkan"], "listen_count": 11}, | |
{"title": "nothing else matters", "artists": ["metallica"], "listen_count": 100}, | |
{"title": "stairway to heaven", "artists": ["led zeppelin"], "listen_count": 90}, | |
{"title": "desert rose", "artists": ["sting", "mahmud fahradi"], "listen_count": 200} | |
] | |
} |
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
import json | |
#import pprint | |
#pp = pprint.PrettyPrinter(2) | |
# ----------- | |
f = open("my_collection.json", "r") | |
contents = f.read() | |
data = json.loads(contents) | |
song_list = data['response'] |
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
import json | |
my_songs = [ | |
{ | |
'title': "Olurum sana", | |
'artists': ["tarkan"] | |
}, | |
{ | |
'title': "nothing else matters", | |
'artists': ["metallica"] |
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
from datetime import date | |
name1 = "kadir" | |
name2 = "hasan" | |
name3 = "osman" | |
x = 3 # int | |
def get_logged_in_user(app): | |
if app == "web": |
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
(defproject lwjgl-demo "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" | |
:url "https://www.eclipse.org/legal/epl-2.0/"} | |
:dependencies [[org.clojure/clojure "1.10.1"] | |
[org.lwjgl/lwjgl "3.3.0"] | |
[org.lwjgl/lwjgl "3.3.0" :classifier "natives-macos"] | |
[org.lwjgl/lwjgl-opengl "3.3.0"] | |
[org.lwjgl/lwjgl-opengl "3.3.0" :classifier "natives-macos"] |
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 lwjgl-demo.core | |
(:gen-class) | |
(:import (org.lwjgl Version) | |
(org.lwjgl.glfw GLFWErrorCallback GLFW GLFWKeyCallbackI Callbacks) | |
(org.lwjgl.opengl GL GL33) | |
(org.lwjgl.system MemoryStack))) | |
; embedded nREPL | |
(require '[nrepl.server :refer [start-server stop-server]]) | |
(defonce server (start-server :port 7888)) |
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
; you may need to find out the name of the 'classifier' for your native OS | |
; here I'm on MacOS | |
[org.lwjgl/lwjgl "3.3.0"] | |
[org.lwjgl/lwjgl "3.3.0" :classifier "natives-macos"] | |
[org.lwjgl/lwjgl-opengl "3.3.0"] | |
[org.lwjgl/lwjgl-opengl "3.3.0" :classifier "natives-macos"] | |
[org.lwjgl/lwjgl-glfw "3.3.0"] | |
[org.lwjgl/lwjgl-glfw "3.3.0" :classifier "natives-macos"] |
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
// notice the visual separation between the group of arguments | |
def testSomething2(something: String)(var1: Double, var2: String) = { | |
println(something + ", var1: " + var1 + ", var2: " + var2) | |
} | |
// here also the visual separation tells that the first two arguments (the data) | |
// is something different from the last argument (function to be called with the data) | |
def runWithVariations2(p1s: List[Int], p2s: List[String])(f: (Double, String) => Unit) = { | |
for (p1 <- p1s; | |
p2 <- p2s) { |
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
// if we do not use currying... | |
// this is the sample test code | |
def testSomething(something: String, var1: Double, var2: String) = { | |
println(something + ", var1: " + var1 + ", var2: " + var2) | |
} | |
// this function runs a function with possible variations | |
def runWithVariations1(v1s: List[Int], v2s: List[String], f: (Double, String) => Unit) = { | |
for (v1 <- v1s; |
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 nestedCurrying(a: Int)(b: String)(c: Double) = { | |
println("a: " + a + ", b: " + b + ", c: " + c) | |
} | |
def g1 = nestedCurrying(1) _ // we pass first param | |
def g2 = g1("str") // and then second param | |
g2(3.14) // and use it with third param | |
NewerOlder