Skip to content

Instantly share code, notes, and snippets.

View TeamSPoon's full-sized avatar

Douglas R. Miles TeamSPoon

View GitHub Profile
use hyperon::metta::*;
use hyperon::metta::interpreter::*;
fn main() {
let space = metta_space("
(= (if True $a) $a)
(= (if False $a) nop)
(= (and True True) True)
(= (and True False) False)
(= (and False True) False)
@patham9
patham9 / gist:ee21bf485a2565ebcd0450ccccc557c8
Last active August 3, 2023 13:01
ONA-like procedure learning for Hyperon in MeTTa (FIXED) (simplified POC to get used to MeTTa)
// Term registration whether it is an operation or not
(= (isop opleft) True)
(= (isop opright) True)
(= (isop opnop) True)
(= (isop ballleft) False)
(= (isop ballhit) False)
(= (isop ballright) False)
// induce implications from event stream
(= (induce $Memory Nil) $Memory)
@aphyr
aphyr / minikanren.pl
Created October 12, 2020 22:10
Minikanren in Lisp in Prolog
:- use_module(library(pairs)).
:- use_module(library(reif)).
not_in_list(K, L) :-
if_((L = []),
true,
([X | More] = L,
dif(K, X),
not_in_list(K, More))).
?- use_module(library(semweb/sparql_client)).
true.
?- sparql_query('CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o } LIMIT 1',
Row,
[ host('localhost'),
path('/w/index.php/Special:SPARQLEndpoint'),
port(8080) ]).
ERROR: Domain error: `sparql_result_document' expected, found `'application/xml'' (<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, first visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
;; (load "cynd/cb-prolog.lisp")
#+Allegro
(sl::cpushnew :CYC-COMMON-LISP *features*)
#+Allegro
(use-package :CYC)
@jp-diegidio
jp-diegidio / Nan.Kernel.Ex.pl
Created September 3, 2015 01:51
Answer Sources in Prolog (SWI) - Preview
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
Answer Sources in Prolog (SWI) - Preview
Answer Sources: Extensions
Copyright (c) 2015 Julio P. Di Egidio
http://julio.diegidio.name/
All rights reserved.
Answer Sources: Extensions
--------------------------
@jp-diegidio
jp-diegidio / MinimiseCandies.pl
Last active August 29, 2015 14:27
Prolog Puzzles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
How few candies does the teacher need?
--------------------------------------
Problem:
Alice is a teacher of kindergarten. She wants to give some candies to
the children in her class. All the children sit in a line and each of
them has a rating score according to his or her usual performance.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function makeContext() { return { choices:[], trail:[], halted:false }; }
// Push a new choice point onto the stack
function pushChoice( ctx, choiceThunk ) {
ctx.choices.unshift( { thunk:choiceThunk, trailIndex:ctx.trail.length } );
}
@mndrix
mndrix / benchmark.prolog
Created May 7, 2014 15:25
Database predicate benchmarks (SWI Prolog)
:- dynamic asserted_a/1, asserted_z/1.
:- b_setval(global_variable, []).
count(1_000_000).
my_asserta(N) :- asserta(asserted_a(N)).
my_assertz(N) :- assertz(asserted_z(N)).
my_recorda(N) :- recorda(recorded_a, N).
my_recordz(N) :- recordz(recorded_z, N).
my_flag(N) :- flag(some_flag, _, N).

Google Apps Script Document Utilities

  • getAllLinks.js

  • getAllLinks(element) - returns array of all UrlLinks in Document

  • findAndReplaceLinks(searchPattern,replacement) - changes all matching links in Document

  • changeCase.js - Document add-in, provides case-change operations in the add-in Menu.

  • onOpen - installs "Change Case" menu

  • _changeCase - worker function to locate selected text and change text case. Case conversion is managed via callback to a function that accepts a string as a parameter and returns the converted string.

  • helper functions for five cases