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
-- The Y combinator, discovered by Haskell B. Curry, is defined as: Y = \f.(\x.f (x x)) (\x. f (x x)) | |
-- haskell | |
newtype Mu a = Mu (Mu a -> a) | |
y f = (\h -> h $ Mu h) (\x -> f . (\(Mu g) -> g) x $ x) | |
-- javascript | |
const factSource = partial => n => n === 0 ? 1 : n * partial(n - 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
import Data.Functor.Contravariant | |
-- newtype Predicate a = Predicate { getPredicate :: a -> Bool } | |
--instance Contravariant Predicate where | |
-- contramap f (Predicate p) = Predicate (p . f) | |
-- | `- First, map the input... | |
-- `----- then apply the predicate. | |
fb = Predicate (\x -> x > 20) |
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
// compose | |
const compose = (...fns) => x => | |
fns.reduceRight((v, f) => f(v), x); | |
/* | |
const toSlug = compose( | |
encodeURIComponent, | |
join('-'), | |
map(toLowerCase), | |
split(' ') |
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
I had the same issue but manually triggering configure script | |
```(cd ./node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh)``` resolves it. | |
Also - If you want to build app for iOS 12 you have to switch path to the active developer directory | |
```(xcode-select -s /Applications/Xcode-beta.app/Contents/Developer).``` |
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 { Component } from '@angular/core'; | |
import { async, TestBed } from '@angular/core/testing'; | |
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms'; | |
import { By } from '@angular/platform-browser'; | |
import { SyncControlDirective } from './sync-control.directive'; | |
class FormGroupHostComponent { | |
formGroup = new FormGroup({ | |
ctrl: new FormControl('') | |
}); |
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
-- Left identity | |
-- return x >>= f 'same as' f x | |
return 3 >>= (\x -> Just (x+100000)) | |
-- Just 100003 | |
(\x -> Just (x+100000)) 3 | |
-- Just 100003 | |
-- Right identity |
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
// Typescript | |
class Identity { | |
constructor(private x: any) { | |
} | |
map(f: Function): any { | |
this.x = f(this.x); | |
} | |
} | |
const id = new Identity(2); |
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
// Recursive: | |
const factorial = n => | |
n < 2 | |
? 1 | |
: n * factorial(n-1); | |
// Tail-recursive: |
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
// TS | |
const randomColorGenerator = (): string => | |
`#${(Math.random().toString(16) + '0000000').slice(2, 8)}`; | |
// ES6 | |
const randomColorGenerator = () => | |
`#${(Math.random().toString(16) + '0000000').slice(2, 8)}`; | |
// ES5 | |
var randomColorGenerator = function () { |