- Proposal: SE-NNNN
- Authors: Max Moiseev
- Review Manager: TBD
- Status: Awaiting implementation
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
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 |
- Proposal: SE-NNNN
- Authors: Dave Abrahams, Maxim Moiseev
- Review Manager: TBD
- Status: Awaiting review
- Bug: SR-3196
- Previous Proposal: [SE-0104][se104]
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:
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
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)) |
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
string[] strings = new string[] { "1", "123", "12", "12ab", "a", "ab", "abc" }; | |
var res = strings.Where("Length >= 3"); |
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
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 | |
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
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 | |
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
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 -> |
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
type LogOp = | |
| Or | |
| And | |
type Cond = | |
| Eq | |
| Neq | |
| Greater | |
| Less | |
| GreaterOrEqual |
NewerOlder