(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
test = map ((*) 2) >>> filter ((>) 15) >>> drop 3 >>> map show | |
src1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] | |
src2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
res1 = transduce' test src1 :: [String] | |
res2 = transduce' test src2 :: List String |
/** | |
* Retrieves all the rows in the active spreadsheet that contain data and logs the | |
* values for each row. | |
* For more information on using the Spreadsheet API, see | |
* https://developers.google.com/apps-script/service_spreadsheet | |
*/ | |
function readRows() { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var rows = sheet.getDataRange(); | |
var numRows = rows.getNumRows(); |
/** | |
git clone https://github.com/twitter/scalding.git | |
cd scalding | |
./sbt scalding-repl/console | |
*/ | |
import scala.io.Source | |
val alice = Source.fromURL("http://www.gutenberg.org/files/11/11.txt").getLines | |
// Add the line numbers, which we might want later | |
val aliceLineNum = alice.zipWithIndex.toList |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# Original Rails controller and action | |
class EmployeesController < ApplicationController | |
def create | |
@employee = Employee.new(employee_params) | |
if @employee.save | |
redirect_to @employee, notice: "Employee #{@employee.name} created" | |
else | |
render :new | |
end |
I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
This section describes the conventions used here to describe type signatures.
A [T]
is an array-like value (only ever used read-only in this API), i.e., one with an integer length
and whose indexed properties from 0 to length - 1
are of type T
.
A type T?
should be read as T | undefined
-- that is, an optional value that may be undefined
.
package main | |
import( | |
"log" | |
"net/url" | |
"net/http" | |
"net/http/httputil" | |
) | |
func main() { |
(function(global) { | |
global.Functor = function(conf) { | |
Functor.types[conf.key] = { | |
obj: conf.obj, | |
fmap: conf.fmap | |
}; | |
}; | |
Functor.types = {}; |
(function(global) { | |
var types = function(obj) { | |
throw new TypeError("fmap called on unregistered type: " + obj); | |
}; | |
// inefficient as hell, but as long as there aren't too many types.... | |
global.Functor = function(type, defs) { | |
var oldTypes = types; | |
types = function(obj) { | |
if (type.prototype.isPrototypeOf(obj)) { |