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/python3 | |
""" Silly little dag calculator language on ints. """ | |
# ops are defined to return lists for a very good reason | |
ops = {"I": lambda a:[a], \ | |
"A": lambda b:[b,b], \ | |
"X": lambda c, d: [d,c], \ | |
"+": lambda e, f: [e+f], \ | |
"-": lambda g, h: [g-h], \ | |
"*": lambda i, j: [i*j], \ |
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
# whitespace separated list of source directories and desired products | |
sources = common server client | |
products = server client | |
# compiletime flags, constant | |
CXXFLAGS = -Wall -std=c++11 | |
# Initialize the obj and source lists for an arbitrary directory | |
define init | |
$(1)_src = $(wildcard $(1)/*.cpp) |
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
There's not much that will reduce me to tears. Apparently the state of | |
enterprise development is one such thing. I gaze upon the lives of hundreds of | |
thousands of developers and my heart aches for their senseless suffering. | |
I have no blame to place. I wish not to point fingers. | |
We've forgotten where we started: nothing. All has sprung forth from the Void, | |
guided by the Minds between the Chairs and Keyboards. Misshapen eldritch horrors | |
that consume all in sight, warping the Minds into summoning an even bigger | |
fish. When will it end? Where will we be when that which is summoned consumes |
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
while (*node != NULL) { | |
if (/* match condition*/) | |
node = &((*node)->child); | |
else | |
node = &((*node)->next); | |
} |
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/python3 | |
import random | |
# A quick test of a linear max subarray algorithm | |
class Partial: | |
"""Named collection corresponding to a partial sum of a sequence of deltas""" | |
def __init__(self, value, index): | |
self.value = value |
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
noun(man). | |
noun(ball). | |
verb(hit). | |
verb(took). | |
article(the). | |
% Handle splitting sublists | |
is_cat([], B, C) :- | |
B = C. |
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
open("/usr/lib/swipl-7.2.3/lib/x86_64-linux/tls/x86_64/libswipl.so.7.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) | |
open("/usr/lib/swipl-7.2.3/lib/x86_64-linux/tls/libswipl.so.7.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) | |
open("/usr/lib/swipl-7.2.3/lib/x86_64-linux/x86_64/libswipl.so.7.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) | |
open("/usr/lib/swipl-7.2.3/lib/x86_64-linux/libswipl.so.7.2", O_RDONLY|O_CLOEXEC) = 3 | |
open("/usr/lib/swipl-7.2.3/lib/x86_64-linux/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) | |
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 | |
open("/usr/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 | |
open("/usr/lib/swipl-7.2.3/lib/x86_64-linux/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) | |
open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 | |
open("/usr/lib/swipl-7.2.3/lib/x86_64-linux/libgmp.so.10", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) |
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
digit(X) :- member(X,[0,1,2,3,4,5,6,7,8,9]). | |
code([X,Y,Z]) :- digit(X), digit(Y), digit(Z), | |
rule1([X,Y,Z]), | |
rule2([X,Y,Z]), | |
rule3([X,Y,Z]), | |
rule4([X,Y,Z]), | |
rule5([X,Y,Z]). | |
rule1([X,Y,Z]) :- X=6 ; Y=8 ; Z=2. |
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
% Bubble sort in prolog, because bubble sort | |
bubble_sort([],Sorted) :- | |
Sorted = []. | |
bubble_sort([X], Sorted) :- | |
Sorted = [X]. | |
bubble_sort(Terms, Sorted) :- | |
bubble(Terms, Terms), Sorted = Terms ; | |
bubble(Terms, Partials), bubble_sort(Partials, Sorted). |
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
% Sorting algorithms in prolog for the fun of it | |
bubble_sort(List, Sorted) :- % the bubble_sort of List is Sorted only if | |
in_order(List) -> % List satisfying in_order implies | |
List = Sorted % List unifies with (is equivalent to) Sorted | |
; % or | |
bubble(List, Bubbled), % the bubble of List is Bubbled and | |
bubble_sort(Bubbled, Sorted). % bubble_sort of Bubbled is Sorted | |
in_order([]). % empty list satisfies in_order |
OlderNewer