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
| import Vue from 'vue' | |
| import VueRouter from 'vue-router' | |
| Vue.use(VueRouter) | |
| Vue.use(require('vue-resource')) | |
| const router = new VueRouter({ | |
| history : true, | |
| saveScrollPosition: true | |
| }); |
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
| <?php | |
| $c = new \App\Base\Container(); | |
| /** | |
| * Register the CallableResolver we just wrote | |
| * to overwrite the default resolving behaviour of the Slim app | |
| */ | |
| $c['callableResolver'] = function ($c) { | |
| return new \App\Base\CallableResolver($c); // See number 04-CallableResolver.php |
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
| const compose = (...fns) => x => fns.reduceRight((acc, fn) => fn(acc), x) |
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
| const wedhus = compose(hargaKambing, diskon10, times3, add2) | |
| // sama dengan | |
| const wedhus = x => [hargaKambing, diskon10, times3, add2].reduceRight((acc, fn) => fn(acc), x) | |
| // dan | |
| const hasil = wedhus(77) | |
| // sama dengan | |
| const hasil = [hargaKambing, diskon10, times3, add2].reduceRight((acc, fn) => fn(acc), 77) |
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
| const wedhus = x => [hargaKambing, diskon10, times3, add2].reduceRight((acc, fn) => fn(acc), x) | |
| wedhus(77) = [hargaKambing, diskon10, times3, add2].reduceRight((acc, fn) => fn(acc), 77) | |
| // STEP BY STEP | |
| // Iterasi 1: fn = add2, acc = 77 | |
| wedhus(77) = [hargaKambing, diskon10, times3].reduceRight((acc, fn) => add2(77), 77) | |
| // Iterasi 2: fn = times3, acc = add2(77) | |
| wedhus(77) = [hargaKambing, diskon10].reduceRight((acc, fn) => times3(add2(77)), 77) |
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
| const map = (fn, arr) => { | |
| const [head, ...tail] = arr | |
| if (tail[0] === undefined) return [fn(head)] | |
| return [fn(head), ...map(fn, tail)] | |
| } |
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
| const filter = (fn, arr) => { | |
| const [head, ...tail] = arr | |
| if (tail[0] === undefined) return [] | |
| if (fn(head)) { | |
| return [head, ...filter(fn, tail)] | |
| } else { | |
| return [...filter(fn, tail)] | |
| } |
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
| const reduce = (fn, init, arr) => { | |
| const [head, ...tail] = arr | |
| if (tail[0] === undefined) return fn(init, head) | |
| return reduce(fn, fn(init, head), tail) | |
| } |
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
| const length = arr => { | |
| const [head, ...tail] = arr | |
| if (tail[0] === undefined) return 1 | |
| return 1 + length(tail) | |
| } |
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
| const Just = value => ({ | |
| map: f => Just(f(value)), | |
| bind(f) { return this.map(f).join() }, | |
| join: () => value, | |
| isJust: () => true, | |
| isNothing: () => false, | |
| orJust: _ => value | |
| }) | |
| const Nothing = () => ({ |
OlderNewer