Skip to content

Instantly share code, notes, and snippets.

Hunter McMillen mcmillhj

Block or report user

Report or block mcmillhj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mcmillhj
mcmillhj / junction.p6
Last active Apr 30, 2018
Why does the below junction differ in result to the loop?
View junction.p6
#!perl6
my @dates = <May 15>, <May 16>, <May 19>, <June 17>, <June 18>, <July 14>, <July 16>, <August 14>, <August 15>, <August 17>;
sub day (@date) { @date[1] }
sub month (@date) { @date[0] }
sub tell($data) {
@dates.grep({ day($_) eq $data or month($_) eq $data });
}
@mcmillhj
mcmillhj / stack.p6
Last active May 4, 2018
Missing Block error on line 20
View stack.p6
#!perl6
class Stack {
has Int @!store;
method push(Int:D $elem --> Nil) {
push @!store, $elem;
}
method pop(--> Int) {
View floyds-triangle.p6
multi sub floyds-triangle(1 --> List) { 1 .. 1, }
multi sub floyds-triangle(Int:D $n where * > 1 --> List) {
my $nth-triangle-number = $n * ($n + 1) div 2;
return floyds-triangle2($n - 1), $nth-triangle-number - $n ^.. $nth-triangle-number;
}
say floyds-triangle(5);
# (((((1..1) 1^..3) 3^..6) 6^..10) 10^..15
@mcmillhj
mcmillhj / logic-gates.js
Created Nov 11, 2019
casidoo interview question: logic gates
View logic-gates.js
"use strict";
// Using De Morgan's Law each of these logic gates can be implemented using one or more NAND gate.
const nand = (p, q) => !(p && q);
const not = p => nand(p, p);
const and = (p, q) => not(nand(p, q));
const or = (p, q) => nand(nand(p, p), nand(q, q));
const nor = (p, q) => not(or(p, q));
const xor = (p, q) => nand(nand(p, nand(p, q)), nand(q, nand(p, q)));
You can’t perform that action at this time.