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
| !(import! &self (library lib_spaces)) | |
| !(import! &self (library lib_import)) | |
| !(git-import! "https://github.com/patham9/petta_lib_localvlm.git") | |
| !(import_prolog_functions_from_file (library lib_localvlm.pl) (vlm_query vlm_embed)) | |
| !(git-import! "https://github.com/patham9/petta_lib_snapshot.git") | |
| !(import! &self (library lib_snapshot)) | |
| (= (forever) | |
| (progn (case (catch (sread (vlm_query "http://192.168.1.129:2276" | |
| "give me 5 capitals, format is strict S-Expression, output nothing else: ((capital1 country1) ... (cityn countryn))" |
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
| sudo rm -f /usr/local/bin/firefox && \ | |
| sudo tee /usr/local/bin/firefox >/dev/null <<'EOF' | |
| #!/bin/bash | |
| exec open -a Firefox "$@" | |
| EOF | |
| sudo chmod +x /usr/local/bin/firefox |
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 python3 | |
| import math | |
| import rclpy | |
| from rclpy.node import Node | |
| from sensor_msgs.msg import LaserScan | |
| FIXED_LEN = 447 | |
| class ScanSanitizer(Node): | |
| def __init__(self): |
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
| !(import_prolog_function statistics) | |
| (= (BudgetLimitCheck) | |
| (if (> (- (statistics inferences) (get-state &initinferences)) (get-state &inferenceslimit)) | |
| (translatePredicate (shift (pay-for-inferences))) | |
| True)) | |
| (= (AssignBudgetLimit $N) | |
| (progn (change-state! &initinferences (statistics inferences)) | |
| (change-state! &inferenceslimit $N))) |
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
| from sexpdata import loads | |
| from petta import * | |
| metta = PeTTa() | |
| expstring = metta.process_metta_string("!(hello \"world\" (1.0 1))")[0] | |
| print(loads(expstring)) | |
| #Output: | |
| #[Symbol('hello'), 'world', [1.0, 1]] |
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_module(library(readutil)). % read_file_to_string/3 | |
| :- use_module(library(pcre)). % re_replace/4 | |
| :- current_prolog_flag(argv, Args), ( (memberchk(silent, Args) ; memberchk('--silent', Args) ; memberchk('-s', Args)) | |
| -> assertz(silent(true)) ; assertz(silent(false)) ). | |
| %Read Filename into string S and process it (S holds MeTTa code): | |
| load_metta_file(Filename, Results) :- load_metta_file(Filename, Results, '&self'). | |
| load_metta_file(Filename, Results, Space) :- read_file_to_string(Filename, S, []), | |
| process_metta_string(S, Results, Space). |
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
| git clone https://github.com/jazzbox35/MettaWamJam | |
| cd MettaWamJam | |
| docker build -t mettawamjam:latest . | |
| docker run --rm -d --name mwj -p 127.0.0.1:5000:5000 mettawamjam:latest | |
| then run: | |
| python3 RunMeTTaCode.py | |
| python3 RunMutex_and_Transaction.py | |
| python3 RunMM2Code.py |
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
| //Input: Whales are mammals that live in the ocean. | |
| <(whale * ocean) --> live_in>. :|: {1.0 0.9} | |
| //Input: Animals that live in the ocean are marine animals. | |
| <(animal * ocean) --> live_in>. :|: {1.0 0.9} | |
| <animal --> marine_animal>. :|: {1.0 0.9} | |
| //Input: Marine mammals are exposed to pollutant P. | |
| <(marine_animal * pollutant_p) --> are_exposed_to>. :|: {1.0 0.9} |
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
| %Finding divisors | |
| 'find-divisor'(A, B, C) :- | |
| *(B, B, D), | |
| >(D, A, E), | |
| ( E==true | |
| -> C=A | |
| ; C=F, | |
| '%'(A, B, G), | |
| ==(0, G, H), | |
| ( H==true |
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
| (foo 1) | |
| (foo 2) | |
| ;Ok: Leads to unnecessary 'and' and 'empty' invocation in compiled output: | |
| (= (match-single1 $space $pat $ret) | |
| (if (and (= $x (match $space $pat $ret)) (cut)) | |
| $x (empty))) | |
| ;Bad: Leads to unneccesary maybe_call which is expensive: |
NewerOlder