Skip to content

Instantly share code, notes, and snippets.

View MikeMKH's full-sized avatar
:shipit:
Learning about logic programming with Prolog

Mike Harris MikeMKH

:shipit:
Learning about logic programming with Prolog
  • Milwaukee, WI
  • 00:26 (UTC -05:00)
View GitHub Profile
@MikeMKH
MikeMKH / booleans.v
Created April 6, 2017 11:34
Boolean function example in Coq, taken from Boolean section of https://www.seas.upenn.edu/~cis500/current/sf/Basics.html
(* taken from https://www.seas.upenn.edu/~cis500/current/sf/Basics.html *)
Inductive bool : Type :=
| true : bool
| false : bool.
Definition negb (b : bool) : bool :=
match b with
| true => false
| false => true
@MikeMKH
MikeMKH / test.js
Created March 22, 2017 11:47
Basic example of folktale core.check with mocha, expect.js, and jsverify
const jsc = require('jsverify');
const expect = require('expect.js');
const check = require('core.check');
describe('core.check', () => {
describe('given the right type it must pass', () => {
jsc.property('given an int when an int is expected it must pass', jsc.int16,
n => check.assert(check.Number(n)) === n
),
@MikeMKH
MikeMKH / test.js
Last active March 17, 2017 11:49
Basic example of folktale core.arity with mocha, chai, and jsverify
const jsc = require('jsverify');
const {assert} = require('chai');
const pass = () => assert.isOk(true);
const fail = () => assert.fail();
const {nullary, unary, binary, ternary} = require('core.arity');
const {curry} = require('core.lambda');
describe('arity', () => {
@MikeMKH
MikeMKH / test.js
Last active March 15, 2017 11:41
Basic example of S, K, and I in fantasy-combinators using mocha with JSVerify
const {constant, identity/*, substitution*/} = require('fantasy-combinators');
const substitution = f => g => x => f(x)(g(x));
const K = constant;
const I = identity;
const S = substitution;
const expect = require('expect.js');
const jsc = require('jsverify');
@MikeMKH
MikeMKH / test.js
Created March 9, 2017 12:29
Basic Validation example using folktale with mocha and expect.js
const Validation = require('data.validation')
const Success = Validation.Success
const Failure = Validation.Failure
const expect = require('expect.js');
describe('truth', () => {
it('will be true', () => {
expect(true).to.equal(true);
})
@MikeMKH
MikeMKH / test.js
Created March 6, 2017 12:39
Basic Maybe examples using folktale with mocha and expect.js
const Maybe = require('data.maybe');
const Nothing = Maybe.Nothing;
const Just = Maybe.Just;
const expect = require('expect.js');
describe('truth', () => {
it('will be true', () => {
expect(true).to.equal(true);
})
@MikeMKH
MikeMKH / test.js
Created March 2, 2017 12:34
Basic Either examples using folktale with mocha and expect.js
const expect = require('expect.js');
const Either = require('data.either');
const Left = Either.Left;
const Right = Either.Right;
describe('truth', () => {
it('will be true or mocha is not set up right', () => {
expect(true).to.equal(true);
})
});
@MikeMKH
MikeMKH / test.js
Last active February 24, 2017 12:48
Basic Maybe example using folktale with mocha and expect.js
const expect = require('expect.js');
const Maybe = require('data.maybe');
const Nothing = Maybe.Nothing;
const Just = Maybe.Just
describe('truth', () => {
it('will be true', () => {
expect(true).to.equal(true);
})
})
@MikeMKH
MikeMKH / Fibonacci.cs
Created February 7, 2017 12:49
Fibonacci kata in C# using generators with .net core
using System.Collections.Generic;
using System.Linq;
namespace Library
{
public static class Fibonacci
{
public static int Value(int n)
{
return Values(n).Last();
@MikeMKH
MikeMKH / Tests.cs
Created January 12, 2017 12:44
Entity Framework Core example using an InMemoryDatabse along with xUnit.
using System.Linq;
using Data;
using Microsoft.EntityFrameworkCore;
using Xunit;
namespace Tests
{
public class UserContextTests
{
public UserContextTests()