Skip to content

Instantly share code, notes, and snippets.

@amw-zero
amw-zero / option_forwarding.ml
Created February 7, 2024 02:56
Passing an optional through
let g o = match o with
| None -> 0
| Some x -> x
let f o = match o with
| None -> 0
| Some x -> g o
let _ = f (Some 5)
---- MODULE PossibleExtended ----
VARIABLES i, j
vars == << i, j >>
Init == i = FALSE /\ j = FALSE
BodyATrue == /\ i' = TRUE
/\ UNCHANGED j
import {
DBState as DBState,
Client as Client,
ScheduledTransaction as ScheduledTransaction,
CreateRecurringTransaction as CreateRecurringTransaction,
RecurringTransaction as RecurringTransaction,
} from "./react_ui/src/state.ts";
import {
ScheduledTransaction as ScheduledTransactionModel,
import { assert } from "https://deno.land/std@0.149.0/testing/asserts.ts";
import fc from 'https://cdn.skypack.dev/fast-check';
type BufferPosition = {
x: number;
y: number;
}
type ContentIndex = {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def fib(n)
return 1 if n == 0 || n == 1
return fib(n - 1) + fib(n - 2)
end
def fib2(n)
return 1 if n == 0 || n == 1
return fib(n - 1) * fib(n - 2)
end
import React, { useState } from 'react';
import './App.css';
enum SubStateType {
Initial,
Error,
Searching,
Movies
};
let cardColor = c =>
switch (c.suit) {
| Clubs => Black
| Spades => Black
| Diamonds => Black
| Hearts => Red
};
let areCardsDifferentColor = (c1, c2) => cardColor(c1) != cardColor(c2);
let testLegalityOfFiveOfSpadesAndSixOfClubs = () => {
let fiveOfSpades = {suit: Spades, rank: 5};
let sixOfClubs = {suit: Clubs, rank: 6};
let isFiveToSixLegal =
isLegalMove(~source=fiveOfSpades, ~dest=sixOfClubs);
[
Bool.assertEqual(
~expected=false,
type suit =
| Clubs
| Diamonds
| Hearts
| Spades;
type color =
| Red
| Black;