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
| (* A possibly correct unification algorithm implementaion *) | |
| open Printf | |
| type term = F of string * (term list) | V of string | |
| let rec subst subs = function | |
| | V x -> List.fold_left (fun acc (s, t) -> if x = s then t else V x) (V x) subs | |
| | F (x, args) -> | |
| F (x, | |
| List.map (fun arg -> subst subs arg) args) |
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
| def gen(start, f): | |
| return lambda: (start, gen(f(start), f)) | |
| def inc(a): | |
| return a + 1 | |
| g = gen(0, inc) | |
| while True: | |
| x, g = g() | |
| print(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
| --- cpdt/src/DataStruct.v 2020-02-02 12:46:14.000000000 -0300 | |
| +++ cpdt-8.13/src/DataStruct.v 2021-12-05 11:05:01.000000000 -0300 | |
| @@ -117,8 +117,8 @@ | |
| (* end thide *) | |
| End ilist. | |
| -Arguments Nil [A]. | |
| -Arguments First [n]. | |
| +Arguments Nil {A}. | |
| +Arguments First {n}. |
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
| from ast import * | |
| class LetVisitor(NodeTransformer): | |
| def visit_Call(self, node): | |
| self.generic_visit(node) | |
| if ( | |
| type(node.func) is Call |
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
| (* this is the commutativity on Nat.add (the builtin + in Coq) that only simplifies | |
| from the left *) | |
| Theorem add_comm : forall (n m : nat), n + m = m + n. | |
| assert (plus_0_r : forall (n' : nat), n' + 0 = n'). | |
| { induction n'. reflexivity. simpl. rewrite IHn'. reflexivity. } | |
| induction n, m; try reflexivity; simpl; try rewrite plus_0_r; try reflexivity. | |
| - rewrite IHn. simpl. | |
| assert (plus_m_Sn : forall (o p : nat), o + S p = S (o + p)). | |
| { induction o; intros; simpl; try reflexivity. rewrite IHo. reflexivity. } | |
| rewrite plus_m_Sn. reflexivity. |
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
| module Foo where | |
| import Control.Monad.State | |
| {-# ANN module ("hlint: ignore Use <$>") #-} | |
| -- This ^ line disables it | |
| foo :: State Int String | |
| foo = do | |
| x <- 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
| using System; | |
| namespace TodoApi | |
| { | |
| /// <summary> | |
| /// A generic result class that should enough | |
| /// to get rid of exceptions and be general enough | |
| /// for handling all kind of errors. | |
| /// | |
| /// User is forced to handle error case to get success |
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 MyClass() abort | |
| let this = {} | |
| function this.setA() dict | |
| let self.a = 1100 | |
| endfunc | |
| function this.method() dict | |
| return self.a | |
| endfunc |
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
| nums = [ | |
| (lambda f, x: x), | |
| (lambda f, x: f(x)), | |
| (lambda f, x: f(f(x))), | |
| ] | |
| result = 0 | |
| calls = [] | |
| def f(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
| class sym: | |
| def __init__(self, name): | |
| self.name = name | |
| def __str__(self): | |
| return f":{self.name}" | |
| def builtin_func(name): | |
| def inner(f): |