Skip to content

Instantly share code, notes, and snippets.

View iyahoo's full-sized avatar
💭
🛌

Tomoya iyahoo

💭
🛌
View GitHub Profile
@iyahoo
iyahoo / adding.css
Last active September 6, 2018 04:42
css for terminal
/* <system section="theme" selected="terminal"> */
@import url("http://lhcpr.hatenablog.com/css/theme/terminal/terminal.css");
/* </system> */
#title, #blog-description {
padding-left: 0px;
}
/* categories */
(defn remove-duplicate-with-test [test coll]
(loop [new-coll [] src coll]
(if-let [first-element (first src)]
(recur (conj new-coll first-element)
(remove #(test first-element %) src))
new-coll)))
;; (remove-duplicate-with-test = [1 2 3 4 3 2 1])
;; ;=> [1 2 3 4]
@iyahoo
iyahoo / check.clj
Last active September 5, 2018 08:29
levenshetein test
(ns check.core
(:require [clj-fuzzy.metrics :refer [levenshtein]]))
(defn pair-levenshtein-key [nk key]
{key (levenshtein nk (name key))})
;; ex 2.42
(define (enumerate-interval low high)
(if (> low high)
nil
(cons low (enumerate-interval (+ low 1) high))))
(define (flatmap proc seq)
(accumulate append nil (map proc seq)))
@iyahoo
iyahoo / a.cl
Created December 13, 2016 10:40
dynamic scope
(defparameter *global-z* 10)
(let ((f (lambda (x) (+ x *global-z*))))
(let ((*global-z* 3))
(funcall f 3)))
;=> 6
@iyahoo
iyahoo / z.cl
Created December 13, 2016 10:29
clozureeee
(let ((z 5))
(let ((f (lambda (x) (+ x z))))
(let ((z 3))
(funcall f 3))))
@iyahoo
iyahoo / c.cl
Last active December 13, 2016 10:28
clozure
(let ((f (lambda (x) (+ x z 3))))
(let ((z 3))
(funcall f 3)))
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(defun main (n &rest argv)
(declare (ignore argv))
(let* ((nth (parse-integer n))
(adj-mat (make-array (list nth nth))))
(loop :for i :to (1- nth) :do

H会演習

1. 以下に適切なコードを埋めよ

文章を読み込み、その単語と頻出度を返すwordNums関数を書け。 ただし、モジュールData.Listに含まれる関数を使用して良い。

import Data.List
wordNums :: String -> [(String, Int)]
wordNums str = map (\gs -> (head gs, length gs)) grouped_str 
@iyahoo
iyahoo / cltrans.lisp
Created September 4, 2015 12:17
コマンドラインで翻訳するやつ
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(unless (find-package :drakma)
(ql:quickload '(:drakma) :silent t))
(unless (find-package :cl-json)
(ql:quickload '(:cl-json) :silent t))