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
var fetch = require('node-fetch'); | |
// fetch('https://api.github.com/users/jmsevold') | |
// .then(function(res) { | |
// return res.json(); | |
// }).then(function(result) { | |
// url = result.followers_url | |
// }).catch(function (error) { | |
// console.log(error); | |
// }); |
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
var p = new Promise(function(resolve, reject) { | |
if(1 === 1) { // set 1===2 to make it fail | |
resolve('Success!'); | |
} | |
else { | |
reject('Failure!'); | |
} | |
}); |
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
var R = require('ramda'); | |
var list = [1,2,3,4,5]; | |
var filter = R.curry(function(func,array){ | |
return array.filter(func); | |
}) | |
var oddsOnly = function(num){ |
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
var compose = (func1,func2) => { | |
return (arg) =>{ | |
return func1(func2(arg)); | |
}; | |
}; | |
var upCase = (str) => str.toUpperCase(); | |
var exclaim = (str) => `${str}!!!`; |
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
var list = ['a', 'b', 'c','d']; | |
var removeFromArray = (list,index) => { | |
var before = list.slice(0, index); | |
var after = list.slice(index + 1, list.length); | |
var result = before.concat(after); | |
return result; | |
}; | |
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
defmodule ListSum do | |
def sum(list) do | |
sum(list,0) | |
end | |
defp sum([h|t],total) do | |
sum(t, total + h) | |
end | |
defp sum([],total) do |
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
defmodule ListReverse do | |
def reverse(list) do | |
reverse(list,[]) | |
end | |
defp reverse([h|t],result) do | |
reversed = [h] ++ result | |
reverse(t,reversed) | |
end |
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
defmodule Todo do | |
use GenServer | |
# wrap calls to GenServer in public functions | |
def start(list) do | |
{:ok, todo_list} = GenServer.start(__MODULE__,list) | |
todo_list | |
end |
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
defmodule MyApp do | |
use Application | |
# See http://elixir-lang.org/docs/stable/elixir/Application.html | |
# for more information on OTP Applications | |
def start(_type, _args) do | |
import Supervisor.Spec, warn: false | |
children = [ | |
worker(Todo, [[]]) |
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
defmodule MyApp do | |
use Application | |
# See http://elixir-lang.org/docs/stable/elixir/Application.html | |
# for more information on OTP Applications | |
def start(_type, _args) do | |
import Supervisor.Spec, warn: false | |
children = [ | |
worker(Todo, [[]]) |
OlderNewer