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
var Y = require('./y'); | |
function factorial(proc) { | |
return function (n) { | |
return n === 0 ? 1 : (n * proc(n - 1)); | |
} | |
} | |
var fact = Y(factorial); | |
var r = fact(3); | |
console.log(r); |
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
'use strict'; | |
function task(number) { | |
var r = 0; | |
for (var i = 0; i < number; i++) { | |
var frac = 1 / ((3 * i) + 1); | |
r = r + frac; | |
} |
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
var rr = [1,2,3,1,3,4,5]; | |
var r = rr.reduce(function (acc, current) { | |
return acc.indexOf(current) < 0 ? acc.concat(current) : acc; | |
}, []); | |
// r = [1, 2, 3, 4, 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
private def retrieveCounters(counter: String): Unit = { | |
val usergridBaseURL = Usergrid.getInstance().clientAppUrl() // https://api.usergrid.com/my-org/my-app | |
val url = s"$usergridBaseURL/counters?counter=$counter" | |
val request = new UsergridRequest(UsergridHttpMethod.GET, UsergridRequest.APPLICATION_JSON_MEDIA_TYPE, url, Usergrid.authForRequests()) | |
val result = Usergrid.sendRequest(request) | |
println(result.getStatusCode, result.getResponseError.getErrorDescription) | |
} |
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
// run this in VsCode command palette | |
// F# | |
ext install Ionide.ionide-fsharp | |
ext install Ionide.ionide-fake | |
ext install Ionide.ionide-paket | |
// varia | |
ext install nwolverson.ide-purescript | |
ext install UCL.haskelly |
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
# Your init script | |
# | |
# Atom will evaluate this file each time a new window is opened. It is run | |
# after packages are loaded/activated and after the previous editor state | |
# has been restored. | |
# | |
# An example hack to log to the console when each text editor is saved. | |
# | |
# atom.workspace.observeTextEditors (editor) -> | |
# editor.onDidSave -> |
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
package fpmax | |
import scala.util.Try | |
import scala.io.StdIn.readLine | |
object App0 { | |
def main: Unit = { | |
println("What is your name?") | |
val name = readLine() |
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
package me.rafaavila | |
import com.whisk.docker._ | |
trait DockerKafkaService extends DockerKit { | |
def KafkaAdvertisedPort = 9092 | |
val ZookeeperDefaultPort = 2181 | |
lazy val kafkaContainer = DockerContainer("spotify/kafka") |
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
// base function | |
def add(a: Int, b: Int): Int = a + b | |
// curried form | |
def addCurried(a: Int)(b: Int): Int = a + b | |
/** | |
* In scala functions have the method `curried` | |
*/ | |
val addCurriedTwo = (add _).curried |
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 addCurried: Int => Int => Int = (add _).curried | |
print(addCurried(1)(2)) |