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
module Bar | |
( | |
) where | |
import System.IO | |
import System.Environment | |
import Control.Monad | |
import Data.Maybe | |
import Data.List | |
import Control.Monad.Writer |
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
big :: Int | |
big = | |
-- (\x -> x - 1) -- 可以 | |
(-1) -- 不行 | |
$ length | |
$ takeWhile (< 10) | |
$ scanl (\acc x -> sqrt x + acc) 0 [1..] |
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
const Task = require('data.task') | |
const { List, Map } = require('immutable-ext') | |
const { Pair, Sum, Intersection } = require('./monoid') | |
const { findArtist, relatedArtists } = require('./spotify') | |
const Bulk = (...xs) => ({ | |
xs, | |
concat: ys => Bulk(...xs.map( (x, idx) => x.concat(ys.xs[idx]) )), | |
bulkMap: (...fs) => Bulk(...xs.map((x, idx) => fs[idx](x))), | |
toList: _ => xs, |
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
/* | |
- Goal: | |
implmenting something like Pair(a, b) but could accommodate any amount of arguments | |
- Usage: | |
Bulk( Sum(2), Sum(3), Sum(4) ) | |
.concat(Bulk(Sum(1), Sum(1), Sum(1))) | |
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
const Mapp = val => ({ | |
val, | |
// {a: 'aa', b: 'bb'} | |
// f :: v -> value | |
map: f => { | |
const o = {} | |
// let resultArr = Object.keys(val).map((key, idx) => ({ [key]: f(val[key]) })) // 錯的,會變成[{}, {}] | |
Object.keys(val).map((key, idx) => o[key] = f(val[key]) ) |
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
function weight( | |
currentWeight = 82, | |
currentRatio = 0.23, | |
targetRatio = 0.2, | |
dailyBurn = 400 | |
) { | |
const currentFat = currentWeight * currentRatio | |
const currentMuscle = currentWeight - currentFat | |
const targetWeight = currentMuscle / (1 - targetRatio) | |
const loseFat = currentWeight - targetWeight // kg |
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
function weight( | |
currentWeight = 82, | |
currentRatio = 0.23, | |
targetRatio = 0.2, | |
dailyBurn = 400, | |
) { | |
const currentFat = currentWeight * currentRatio | |
const currentMuscle = currentWeight - currentFat | |
const targetWeight = currentMuscle / (1 - targetRatio) | |
const loseFat = currentWeight - targetWeight // kg |
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
/* | |
Usage: | |
import SVGIcon from './Icons.jsx' | |
<SVGIcon kind='edit' style={{width: 48, height:48, fill:'green'}} /> | |
*/ | |
import React, { Component, PropTypes } from 'react' | |
// base icon style | |
const styles = { |
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 hyperarray from 'hyper-array' | |
import memdb from 'memdb' | |
const dag = hyperarray( memdb() ) | |
// step 1 | |
// api: array.insert(value, [before], [after], [cb=function (err, entry) {}]) | |
dag.insert( 'abc', null, null, ( err, node ) => { | |
conole.log( node ) |
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
--[[ | |
- here's a better way to train RNNLM with large dataset, | |
- persist the weights from LookupTable into file | |
- and load it back later to use in sentiment analysis tasks | |
- detailed discussion here: https://github.com/torch/nn/issues/747 | |
- thanks @fmassa for pointing out the direct direction |