Skip to content

Instantly share code, notes, and snippets.

View myaosato's full-sized avatar
🎉
happy hacking

Satoaki MIYAO myaosato

🎉
happy hacking
View GitHub Profile
// 2023-11-16
Array.from(document.querySelectorAll('.a-price-whole')).map(x => Number(x.innerHTML.replace(',', ''))).reduce((s, e) => s + e, 0);
@myaosato
myaosato / proof.lisp
Last active September 6, 2023 14:12
定理証明もどき
; Proof
;
; => https://github.com/myaosato/claudia
;
;; ****************************************************************
;; meta data type
#|
const := const-val | func const*
term := const | var
@myaosato
myaosato / fact.pl
Created February 12, 2022 04:21
Factrial on Prolog
fact(1, F) :- F is 1.
fact(N, F) :-
N > 1,
M is N - 1,
fact(M, T),
F is N * T.
@myaosato
myaosato / binary-heap.lisp
Last active September 26, 2020 15:41
study
;;;; heap
(defstruct (binary-heap (:conc-name bh-))
(predicate #'>=)
(nodes (make-array (list 1024) :adjustable t :fill-pointer 0)))
(defun bh-empty (binary-heap)
(= (length (bh-nodes binary-heap)) 0))
(defun bh-tail (binary-heap)
(1- (length (bh-nodes binary-heap))))
@myaosato
myaosato / bar.py
Last active September 5, 2020 00:13
Pythonプロセス並列化お試し
# 1秒後, 2秒後 3秒後に印字されるものと,
# 2秒後, 3秒後 に印字される
import time
import sys
from multiprocessing import Process, Value, set_start_method
set_start_method('fork')
def f(xs, flg):
cnt = 0
fib(N, F) :- fibo(0, 1, N, F).
fibo(A, _B, 0, F) :- F is A.
fibo(A, B, N, F) :-
N > 0,
NEWA is B,
NEWB is A + B,
NEWN is N - 1,
fibo(NEWA, NEWB, NEWN, F).
(defpackage :cl-ulid/cl-ulid
(:use :cl)
(:nicknames :cl-ulid)
(:export :ulid))
(in-package :cl-ulid)
(defun get-epoch-millisecond ()
#+sbcl
(multiple-value-bind (sec microsec) (get-time-of-day)
(+ (* 1000 sec) (round (/ microsec 1000))))
(defmacro -> (prev &rest rest)
(if (null rest)
prev
`(-> ,(cons (caar rest) (cons prev (cdar rest))) ,@(cdr rest))))
(defmacro ->> (prev &rest rest)
(if (null rest)
prev
`(->> ,(append (car rest) (list prev)) ,@(cdr rest))))