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
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/socket.h> | |
#include <sys/types.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
#include <netdb.h> |
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 token_id = nat | |
type amount = nat | |
type balance_key = { | |
owner : address; | |
token_id : token_id | |
} | |
type balance_map = (balance_key, amount) map | |
type storage = balance_map | |
type parameter = |
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
(* Make sure you have taglib installed. Find complete | |
documentation at https://github.com/savonet/ocaml-taglib/blob/master/src/taglib.mli *) | |
(* We write a small program that either displays or modifies a given | |
tag for a given audio file. | |
Usage example: | |
./main.exe get artist my_song.mp3 | |
or | |
./main.exe set artist BikaBika my_song.mp3 *) |
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
import Test.QuickCheck | |
-- unfortunately, function names cannot start with uppercase letters | |
r :: Positive Integer -> Positive Integer -> Bool | |
r a b = | |
let (x, y) = (getPositive a, getPositive b) in | |
y `mod` (x * x) == 0 | |
implies p q = not p || q |
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 step (x, y) = | |
(* Match on a random integer between 0 and 3 | |
* incrementing or decrementing either x or y | |
* depending on the result. The pattern matching | |
* is not exhaustive, but because we know | |
* Random.int 4 can only return a number between | |
* 0 and 3, this is okay. *) | |
match Random.int 4 with | |
| 0 -> (x + 1, y) | |
| 1 -> (x - 1, y) |
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
module List = | |
// Some code for generating permutations of a list | |
// Please disregard it, I copied it off the internet :) | |
let rec permutations l = | |
let rec aux = function | |
| [] -> seq [List.empty] | |
| x :: xs -> Seq.collect (insertions x) (aux xs) | |
aux l |> Seq.toList | |
and insertions x = function | |
| [] -> [[x]] |
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
-- The relation R defined as a function: | |
-- Takes two integers and returns true | |
-- if aRb and false otherwise | |
r :: Integer -> Integer -> Bool | |
-- Why gcd? The relation r can be | |
-- redefined in a way that's more | |
-- convenient to represent computationally: | |
-- aRb if the numerator and denominator | |
-- of the simplest form of a/b are both odd. |
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
#r "nuget: FSharp.Data" | |
open FSharp.Data | |
open System.IO | |
let args = System.Environment.GetCommandLineArgs() | |
let first = int <| args.[2] | |
let last = int <| args.[3] | |
let fetchPageAsync i = | |
async { |
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
private static <Key extends Comparable<Key>, Value> boolean isRed(Node<Key, Value> root) { | |
return root != null && root.isRed; | |
} | |
private static <Key extends Comparable<Key>, Value> int size(Node<Key, Value> root) { | |
if (root == null) return 0; | |
return 1 + size(root.left) + size(root.right); | |
} | |
private static <Key extends Comparable<Key>, Value> Node<Key, Value> leftRotate(Node<Key, Value> root) { |
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
#r "nuget: FSharp.Data" | |
open FSharp.Data | |
let args = System.Environment.GetCommandLineArgs() | |
let flags = | |
if args.Length > 3 then | |
args.[2..(args.Length - 2)] | |
else | |
[||] |
NewerOlder