récuperer le react transform boilerplate. => workflow hot swaping trop cool ;)
git clone https://github.com/gvergnaud/prez-react.git TutoReact
npm install
npm start
import { compose, curry, map } from 'ramda' | |
import Const, { getConst } from './functors/Const' | |
import Identity, { runIdentity } from './functors/Identity' | |
import K from './functors/K' | |
/* ----------------------------------------- * | |
Lenses définition | |
* ----------------------------------------- */ |
export default class Const { | |
constructor(v) { | |
this.value = v | |
} | |
static of(v) { | |
return new Const(v) | |
} |
export default class Identity { | |
constructor(v) { | |
this.value = v | |
} | |
static of(v) { | |
return new Identity(v) | |
} |
const stateIdLens = propLens('id') | |
const stateTokenLens = propLens('token') | |
let setCurrentUserId = (state, action) => set(idLens, action.payload.result, state) | |
let setCurrentUserToken = (state, action) => set(tokenLens, action.payload.token, state) | |
compose(setCurrentUserId, setCurrentUserToken) | |
export type Option<T> = | |
| { readonly type: 'some'; readonly value: T } | |
| { readonly type: 'none' }; | |
export const none: Option<never> = { type: 'none' }; | |
export const some = <T>(value: T): Option<T> => ({ type: 'some', value }); | |
const compose = |
/* ----------------------------------------- * | |
Learning Machin Learning | |
* ----------------------------------------- */ | |
import { compose, map, chain, range } from 'ramda' | |
// Result = { a :: Int, b :: Int, cost :: Number } | |
// Data = [Int, Int] | |
// Tupple = [Int, Int] | |
// findBestResult :: [Result] -> Result |
/* ----------------------------------------- * | |
Learning Machin Learning | |
* ----------------------------------------- */ | |
// gradientDescent for the square error function and a Theta of Two parameter (a, b) | |
// Theta :: [Number, Number] | |
// sum :: (a -> Int) -> List a -> Int | |
const sum = (transformer, list) => | |
list.reduce((acc, item) => acc + transformer(item), 0) |
/* --------------------------------------------------------------------------- * | |
Utilities for managing lists, implemented using only recursion | |
* --------------------------------------------------------------------------- */ | |
const head = ([x]) => x | |
const tail = ([x, ...rest]) => rest | |
const last = xs => xs[xs.length - 1] |
/* ----------------------------------------- * | |
Learning Machin Learning | |
* ----------------------------------------- */ | |
// gradientDescent of the square error function for a Theta of any number of | |
// parameters | |
// multiplyVectors :: List number -> List number -> number | |
const multiplyVectors = (xs, ys) => | |
xs.reduce((acc, x, i) => acc + x * ys[i], 0) |