I hereby claim:
- I am moiseev on github.
- I am moiseev (https://keybase.io/moiseev) on keybase.
- I have a public key whose fingerprint is 4CD1 7F10 0D47 6566 7D6F F955 5B0C F4A4 E73E 4354
To claim this, I am signing this object:
let rec toExpr (par:ParameterExpression) (clause: Clause) = | |
let constExpr (x:'a) = | |
Expression.Constant(x, typeof<'a>) |> asExpr | |
let callExpr (i:Expression) (m:String) (p:Expression) = | |
Expression.Call(i, m, Array.empty, p) | |
let arrExpr (xs:'a array) = | |
Expression.NewArrayInit(typeof<'a>, Array.map (constExpr >> asExpr) xs) |> asExpr | |
let inExpr (vEx:Expression) (arrEx:Expression) = | |
Expression.Call(typeof<Enumerable>, "Contains", [|vEx.Type|], arrEx, vEx) |> asExpr |
type LogOp = | |
| Or | |
| And | |
type Cond = | |
| Eq | |
| Neq | |
| Greater | |
| Less | |
| GreaterOrEqual |
let foldClause simpleF complexF clause = | |
let unitem = function | |
| Prop ss -> ss | |
let rec loop clause cont = | |
match clause with | |
| Simple (item, condition, value) -> | |
cont (simpleF (unitem item) condition value) | |
| Complex (l, op, r) -> | |
loop l (fun lval -> | |
loop r (fun rval -> |
let toExpr (par:ParameterExpression) (clause: Clause) = | |
let constExpr (x:'a) = | |
Expression.Constant(x, typeof<'a>) |> asExpr | |
let callExpr (i:Expression) (m:String) (p:Expression) = | |
Expression.Call(i, m, Array.empty, p) | |
let arrExpr (xs:'a array) = | |
Expression.NewArrayInit(typeof<'a>, Array.map (constExpr >> asExpr) xs) |> asExpr | |
let inExpr (vEx:Expression) (arrEx:Expression) = | |
Expression.Call(typeof<Enumerable>, "Contains", [|vEx.Type|], arrEx, vEx) |> asExpr | |
type IClauseVisitor<'TState> = | |
abstract member Simple : String array * Condition * Val -> 'TState | |
abstract member Complex : 'TState * LogicalOperation * 'TState -> 'TState | |
let visitClause (visitor:#IClauseVisitor<'TState>) clause = | |
let simpleF props (cond:Cond) value = visitor.Simple(props, (cond.ToEnum()), value) | |
let complexF left (logOp:LogOp) right = visitor.Complex(left, (logOp.ToEnum()), right) | |
Clause.Fold simpleF complexF clause | |
string[] strings = new string[] { "1", "123", "12", "12ab", "a", "ab", "abc" }; | |
var res = strings.Where("Length >= 3"); |
def append(xs, yss): | |
return [[x] + ys for x in xs for ys in yss] | |
def make_lists(*xss): | |
if len(xss) == 1: | |
return [[x] for x in xss[0]] | |
h, t = xss[0], xss[1:] | |
return append(h, make_lists(*t)) |
I hereby claim:
To claim this, I am signing this object:
public protocol Dividable { | |
static func / (lhs: Self, rhs: Self) -> Self | |
} | |
extension Int : Dividable {} | |
extension Double : Dividable {} | |
extension Sequence where Element : Numeric & Dividable { | |
func average() -> Element { | |
var i: Element = 0 |