Skip to content

Instantly share code, notes, and snippets.

View kmizu's full-sized avatar

Kota Mizushima kmizu

View GitHub Profile
@kmizu
kmizu / o3-prolog.html
Created February 3, 2025 05:44
Prolog inrepreter by o3-mini-high
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>JavaScript Prolog インタプリター</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: #f2f2f2;
@kmizu
kmizu / o3-mini-high-thinking.txt
Created February 3, 2025 05:40
Thinking to create Prolog Interpreter
Mapping out the solution
I’m piecing together a JavaScript-based Prolog interpreter, leveraging HTML for browser functionality and CSS for a sleek interface. This requires implementing a minimal Prolog subset like basic facts and queries.
Planning the layout
I’m crafting an HTML file with embedded CSS and JavaScript for a Prolog interpreter. It includes areas for Prolog code input, query input, a button to run queries, and an output division.
Mapping a plan
Crafting a JavaScript-based Prolog interpreter with depth-first search resolution for Horn clauses. Including a simple parser and basic query handling.
Breaking down the solution
I’m developing a JavaScript code to parse Prolog rules, store them in a database, and implement a resolution algorithm for queries. Clauses will be represented as {head: Term, body: [Term]}.
Mapping out Prolog parsing
I’m considering a simplified parser for Prolog terms, focusing on atoms and structures with functor and arguments, while adhering to a limited format like “parent(jo
Classfile /Users/kota.mizushima/repo/S.class
Last modified 2025/01/29; size 1141 bytes
SHA-256 checksum 65b4550564c5c46318684ff0631b603d4030a9d58ccc738d1ea2c355dd195f6f
Compiled from "S.java"
class S
minor version: 0
major version: 65
flags: (0x0020) ACC_SUPER
this_class: #14 // S
super_class: #2 // java/lang/Object
@kmizu
kmizu / HigAndLow.j
Created January 29, 2025 04:30
High and Low
Classfile /Users/kota.mizushima/repo/HighAndLow.class
Last modified 2025/01/29; size 1509 bytes
SHA-256 checksum 9f7e5f532ca17d7e41b24a14633833e16c0b95df2335adf465b063ab624bd730
Compiled from "HighAndLow.java"
public class HighAndLow
minor version: 0
major version: 65
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #56 // HighAndLow
super_class: #2 // java/lang/Object
@kmizu
kmizu / Fib.j
Created January 29, 2025 04:08
Fibonacci function
Classfile /Users/kota.mizushima/repo/Fib.class
Last modified 2025/01/29; size 953 bytes
SHA-256 checksum 58d114f5e4a48ff95933c8c9d90b42e8998060a6bc5f8e56fa4c1464ce4f1832
Compiled from "Fib.java"
public class Fib
minor version: 0
major version: 65
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_class: #8 // Fib
super_class: #2 // java/lang/Object
const readline = require('readline');
const fs = require('fs');
const readLineSync = require('readline-sync');
const { type } = require('os');
function input(prompt) {
return readLineSync.question(prompt);
}
function arrayEquals(arr1, arr2) {
return (
@kmizu
kmizu / prompt.txt
Created October 24, 2024 09:12
インタプリタの実装からプログラムを導出する
Here is my program lang. Could you provide number guessing game in the lang?
const readline = require('readline');
const fs = require('fs');
const readLineSync = require('readline-sync');
function input(prompt) {
return readLineSync.question(prompt);
}
//プログラム全体
@kmizu
kmizu / lang-after.js
Last active October 4, 2024 13:50
o1-previewの力
// Program class
class Program {
constructor(defs, ...expressions) {
this.defs = defs;
this.expressions = expressions;
}
} // Function definition class
class FunDef {
constructor(name, args, body) {
this.name = name;
@kmizu
kmizu / A1.txt
Last active May 4, 2023 12:18
「柔らかく言い換える」Chrome拡張を作ってくれるようにGPT-4にお願いしてみた
もちろんです!以下に、Chrome拡張機能を作成するためのコードの例を示します。これは、指定された仕様を満たすシンプルな拡張機能です。
まず、プロジェクトディレクトリに3つのファイルを作成してください。
manifest.json
background.js
content.js
manifest.json:
@kmizu
kmizu / ChatGPT.js
Created March 3, 2023 09:25
Google Apps Script to use ChatGPT API
function doPost(e) {
// slack appsのEvent Subscriptionsのchallenge。同期する時に利用。
var params = JSON.parse(e.postData.getDataAsString());
if('challenge' in params)
{
return ContentService.createTextOutput(params.challenge);
}
// ユーザ名とtextを取得
var userName = params.event.user;