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
| var success; | |
| var board[8]; | |
| var yokoArray[8]; | |
| var leftUpper[88]; | |
| var rightUpper[88]; | |
| main() { | |
| var max, state; | |
| max = 8 * 8 * 8 * 8 * 8 * 8 * 8 * 8; | |
| state = 0; |
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
| #include<stdio.h> | |
| void check(int*); | |
| int success; | |
| int main(void) { | |
| int max = 8 * 8 * 8 * 8 * 8 * 8 * 8 * 8; | |
| int state = 0; |
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
| all: y.tab.c lex.yy.c | |
| cc -DYYERROR_VERBOSE -DYYDEBUG -o Parse y.tab.c lex.yy.c | |
| y.tab.c: | |
| yacc -dv parser.y | |
| lex.yy.c: y.tab.c | |
| lex parser.l |
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
| use v6; | |
| grammar Expression { | |
| rule num { \d+ } | |
| rule qexp { '(' <exp> ')' } | |
| rule atom { <exp2> || <num> || <qexp> } | |
| rule ops { <.ws><ops1><.ws> || <.ws><ops2><.ws> } | |
| token ops1 { '+'|'-' } | |
| token ops2{ '*'|'/' } | |
| rule exp { <atom>+ % <ops> } |
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
| use v6; | |
| class Settings { | |
| has Int $.port; | |
| has Str $.document_root; | |
| method new(Str $path) { | |
| my @settings = $path.IO.lines; | |
| my $portline = @settings.grep(/port\=<.digit>*$$/)[0]; | |
| my $port = $portline.substr(5).Int; |
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
| use v6; | |
| role Value[::Type] { | |
| has Type $.value; | |
| has @.exp; | |
| multi method new (Type $v, @exp) { | |
| self.bless(*, value => $v, exp => @exp); | |
| } | |
| } |
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
| let rec balance (t:'a tree) : int tree = | |
| let rec height t = | |
| match t with | |
| | Br(_,left,right) -> | |
| let (hl, hr) = (height left, height right) in | |
| if (hl > hr) then hl + 1 else hr + 1 | |
| | _ -> 0 | |
| in | |
| match t with | |
| | Br(value, left, right) -> Br(height left - height right, balance left, balance right) |
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
| let diff xs ys = | |
| let rec internal xs ys ans = | |
| match xs with | |
| | hd::tl -> | |
| if List.mem hd ys then internal tl ys ans | |
| else internal tl ys (ans @ [hd]) | |
| | _ -> ans | |
| in | |
| internal xs ys [];; | |
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
| #!/usr/bin/env perl | |
| use 5.12.0; | |
| my $usage = <<EOS | |
| usage: \$runocaml filename | |
| EOS | |
| ; | |
| my $filename = shift // die "Error: No filename \n$usage"; | |
| -f $filename or die "$filename not found.\n$usage"; |
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
| let cut l n = | |
| List.fold_left ( | |
| fun prev next -> | |
| if (List.fold_left (fun prev next -> prev + next) 0 prev) + next > n | |
| then prev | |
| else prev @ [next] | |
| ) [] l;; | |
| cut [1;2;3;4;5;6;7;8;9] 18;; |