Skip to content

Instantly share code, notes, and snippets.

@patham9
patham9 / gist:b89ef4b8d7d40782766889b833ac5495
Created May 20, 2025 09:06
MeTTa Motto (rel extraction test)
!(import! &self motto)
!(let $x ((chat-gpt-agent "gpt-4o-mini")
(system "You are an assistant. Answer as a tuple (R a b) (no commas) where R in {near} and a,b in {human, robot, chair}")
(user "the robot is close to the chair!"))
(let $L ((py-dot ((py-dot ((py-dot $x replace) "(" "" ) replace) ")" "") split) " ")
(let ($R $a $b)
(((py-dot $L __getitem__) 0)
((py-dot $L __getitem__) 1)
((py-dot $L __getitem__) 2))
(EXTRACTED: (R = $R) (a = $a) (b = $b)))))
@patham9
patham9 / gist:276120eaf098bb2eeec274cff01a056f
Last active December 11, 2024 20:30
ROS2 Nav2 goal abortion
[component_container_isolated-10] [INFO] [1733948499.855052061] [controller_server]: Received a goal, begin computing control effort.
[component_container_isolated-10] [INFO] [1733948502.957650038] [controller_server]: Passing new path to controller.
[component_container_isolated-10] [ERROR] [1733948503.930128544] [planner_server]: Failed to create a plan from potential when a legal potential was found. This shouldn't happen.
[component_container_isolated-10] [WARN] [1733948503.930219308] [planner_server]: GridBased plugin failed to plan from (1.36, 1.68) to (2.80, 1.17): "Failed to create plan with tolerance of: 0.500000"
[component_container_isolated-10] [WARN] [1733948503.930227143] [planner_server]: [compute_path_to_pose] [ActionServer] Aborting handle.
[component_container_isolated-10] [INFO] [1733948503.956205964] [controller_server]: Passing new path to controller.
[component_container_isolated-10] [ERROR] [1733948503.956302770] [controller_server]: Path is empty.
[component_container_isolated-10] [INF
@patham9
patham9 / airis.py
Last active December 27, 2023 17:28
Berick Cook's AIRIS replicated by Patrick Hammer from his video and discussions with him.
from collections import deque
from copy import deepcopy
import sys
import time
import random
# THE WORLD
world = """
oooooooooooo
o o f o
@patham9
patham9 / parallel-amb.scm
Last active November 30, 2023 18:51
Parallel amb (Chicken Scheme)
(define-syntax amb-parallel
(syntax-rules ()
((_ arg1 arg2)
(receive (pipefd0 pipefd1) (create-pipe)
(let ((pid (process-fork)))
(if (eq? pid 0)
(let ((pipefd1_port (open-output-file* pipefd1)))
(write (amb-collect arg2) pipefd1_port) ;we can't backtrack into parent so we collect all of this level's results
(close-output-port pipefd1_port)
(exit 0)) ;child is done
@patham9
patham9 / parallel-list.scm
Last active November 30, 2023 18:17
Parallel list (Chicken Scheme)
(import (chicken process) (chicken file posix))
(define-syntax parallel-list
(syntax-rules ()
((_ arg1 arg2)
(receive (pipefd0 pipefd1) (create-pipe)
(let ((pid (process-fork)))
(if (eq? pid 0)
(begin (write arg1 (open-output-file* pipefd1))
(exit 0)) ;child is done
@patham9
patham9 / parallel-amb.scm
Last active November 30, 2023 18:05
Parallel amb
(import (chicken process) (chicken string) (chicken file posix) amb)
(define-syntax amb-parallel
(syntax-rules ()
((_ arg1 arg2)
(let-values (((pipefd0 pipefd1) (create-pipe)))
(let ((pid (process-fork)))
(begin (if (eq? pid 0)
(begin (file-write pipefd1 (string-append (->string arg1) "\n"))
(exit 0)) ;child is done
@patham9
patham9 / gist:9af1fb750ed37dd3b0c31c3740e7ccd9
Last active November 7, 2023 18:52
Mettamorph speedup (Processor: 1,6 GHz Dual-Core Intel Core i5, OS: macOS Monterey)
python3 timing.py
Starting 4 tests with 10 runs each, grab a coffee!
==
Compilation started.
Compilation complete.
TEST: !(factorial 30)
[265252859812191058636308480000000]
[265252859812191058636308480000000]
........
Time MeTTa: avg=3.9196492433547974 seconds, var=0.019423207564014434
(! (add-atom '&self ('coffee 'moka)))
(! (add-atom '&self ('coffee 'turkish)))
(= (myMultiFunction 'moka) ('moka 'good))
(= (myMultiFunction 'moka) ('moka 'excellent))
(! (Let w (superpose ('big 'small myMultiFunction))
(Match '&self ('coffee x) (w x))))
Output:
;[((big turkish)), ((big moka)), ((small turkish)), ((small moka)), ((moka excellent)), ((moka good))]
(coffee moka)
(coffee turkish)
(coffee expresso)
(coffee cappuccino)
(coffee latte)
!(match &self (coffee $1) $1)
(define %coffee
(%rel ()
[('moka)]
[('turkish)]
[('expresso)]
[('cappuccino)]
[('latte)]))
(define (test data)
(if data