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
#!/usr/bin/env python | |
# As you know there is NO Assignment in Lambda Calculus (LC), | |
# and all those functions must be inlined using LC's | |
# substitution rule. But if I do that this code will look extremely | |
# gross and unreadable. So I keep it this way for comprehensibility | |
# reasons. | |
# | |
# This was SO MUCH fun to implement and quite an interesting puzzle | |
# to solve. This whole thing was completely inspired by Gary Bernhardt's |
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
zero = \f -> \x -> x | |
mySucc = \n -> \f -> \x -> f $ n f x | |
add = \n -> \m -> n mySucc m | |
mkPair = \a -> \b -> \s -> s a b | |
myFst = \a -> \b -> a | |
mySnd = \a -> \b -> b | |
step = \p -> mkPair (p mySnd) (mySucc (p mySnd)) | |
nSteps = \n -> \p -> n step p | |
zz = mkPair zero zero | |
myPred = \n -> (nSteps n zz) myFst |
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
# Shape a matrix and we only use the half | |
# in which the col-number >= row-number! | |
# m[i][j] stores the sum of values in the | |
# sub-array from i to j (i.e nums[i:(j + 1)]) | |
# and to calculate each new sub-array we can | |
# leverage the previously calculated sub-array | |
# which didn't have this new element and add | |
# this new element on top of that: | |
# | |
# m[i][j] = m[i][j - 1] + nums[j] |
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
{-# LANGUAGE InstanceSigs #-} | |
import Data.Char | |
import Control.Applicative | |
newtype Parser a = Parser { runParser :: String -> Maybe (a, String) } | |
instance Functor Parser where | |
fmap :: (a -> b) -> Parser a -> Parser b | |
fmap f pa = Parser $ \s -> fmap (first f) (runParser pa s) |
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
package com.uber.gairos.flink.operator.flink_operator; | |
import lombok.Builder; | |
import lombok.Getter; | |
import lombok.Setter; | |
import lombok.NoArgsConstructor; | |
import lombok.AllArgsConstructor; | |
import lombok.ToString; | |
import org.apache.flink.api.common.ExecutionConfig; | |
import org.apache.flink.api.common.functions.AggregateFunction; |
OlderNewer