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 { | |
| zipObj, | |
| values, | |
| pipe, | |
| map, | |
| split, | |
| last, | |
| keys, | |
| equals | |
| } from 'ramda'; |
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 co from 'co' | |
| co(function *() { | |
| try { | |
| yield Promise.reject('sandro'); | |
| } catch (e) { | |
| console.log(e); | |
| } | |
| let [a, b] = yield [ |
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
| $xs = User::where('name', 'leven') | |
| ->orderBy('name') | |
| ->take(10) | |
| ->get(); | |
| $ys = User | |
| ::where('name', 'leven') | |
| ->orderBy('name') | |
| ->take(10) | |
| ->get(); |
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 Prelude hiding (takeWhile, dropWhile) | |
| takeWhile :: (a -> Bool) -> [a] -> [a] | |
| takeWhile p xs = snd $ foldl reducer (True, []) xs | |
| where reducer = \(take, xs) x -> if take && p x then (True, xs ++ [x]) else (False, xs) | |
| dropWhile :: (a -> Bool) -> [a] -> [a] | |
| dropWhile p xs = snd $ foldl reducer (True, []) xs | |
| where reducer = \(drop, xs) x -> if drop && p x then (True, xs) else (False, xs ++ [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
| var R = require('ramda'); | |
| // in production code, don't forget bounds check. | |
| var removeAtIndex = (n, xs) => R.concat(R.take(n, xs), R.drop(n+1, xs)); | |
| console.log(R.eqDeep(['B', 'C'], removeAtIndex(0, ['A', 'B', 'C']))); | |
| console.log(R.eqDeep(['A', 'C'], removeAtIndex(1, ['A', 'B', 'C']))); | |
| console.log(R.eqDeep(['A', 'B'], removeAtIndex(2, ['A', 'B', 'C']))); |
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
| using System; | |
| using System.Collections.Generic; | |
| namespace Closure | |
| { | |
| class Closure | |
| { | |
| static List<Action> ClosureIncorrect() | |
| { | |
| var actions = new List<Action>(); |
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
| function mkhedruliToAsomtravruli(mkhedruliString) { | |
| return mkhedruliString | |
| .split("") | |
| .map(function(mkhedruliChar) { | |
| return String.fromCharCode(mkhedruliChar.charCodeAt(0) - 48); | |
| }) | |
| .join(""); | |
| } | |
| mkhedruliToAsomtravruli("სანდრო"); // outputs ႱႠႬႣႰႭ |
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
| // ეს კოდი სვიფტში უპრობლემოდ კომპილირდება | |
| typealias რიცხვი = Int | |
| func მიმატება(ა: რიცხვი, ბ: რიცხვი) -> რიცხვი { | |
| return ა + ბ | |
| } | |
| მიმატება(1, 2) |
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
| enum List<T> { | |
| case Empty | |
| case Cons(head: T, tail: List<T>) | |
| } |
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
| choose :: [b] -> Int -> [[b]] | |
| _ `choose` 0 = [[]] | |
| [] `choose` _ = [] | |
| (x:xs) `choose` k = (x:) `fmap` (xs `choose` (k-1)) ++ xs `choose` k |