Skip to content

Instantly share code, notes, and snippets.

%% Erlang Programming Exercise 3-10
%% https://gist.github.com/yamasushi/69d6f5ab6cd7115ab525fe011ec67dfe
-module(ex310).
-export([test_data/0,fill/2,justify/2]).
fill(Words,Width) ->
GW = gather_words_acc(Words,Width,0,0,[],[]),
%% io:format("~p~n",[GW]),
lists:foreach(fun(K)->io:format("~s~n",[K]) end ,
lists:map(fun({_,L}) -> fill_line(L) end, GW)).
@yamasushi
yamasushi / proc.jl
Last active May 12, 2019 07:31
プロセスの使用
#https://gist.github.com/yamasushi/355dec4cf1bf644a758279a80ff1cafa
open(`ls -a`) do p
while !eof(p) println(readline(p)) end
end
@yamasushi
yamasushi / totient.jl
Last active May 12, 2019 05:02
(オイラーの)totient関数の性質
# https://gist.github.com/yamasushi/873992c10d8ac74750f3fa9d3ec039f4
# https://qiita.com/yamasushi/items/fc0d4c77d26bb5d05ed3
using DataFrames
using Primes
n=30
@show(n)
gcds = gcd.(n,1:n)
df=DataFrame(
module DynamicalSystem
using ColorTypes
export make_seq , push_points!
struct Seq{P}
initial::P
fn::Function
end
Base.iterate(ds::Seq, pt=ds.initial ) = (pt, ds.fn(pt) )
#!/usr/bin/env gosh
; https://gist.github.com/yamasushi/4c4353a6e710758acec9
(use gauche.parseopt)
(use file.util)
(use srfi-11)
(define (main args) (let-args (cdr args)
( (help "h|help")
@yamasushi
yamasushi / cat.scm
Last active January 26, 2016 09:03
#!/usr/bin/env gosh
; https://gist.github.com/yamasushi/f9a42af9936805d1cc2f
(use gauche.parseopt)
(use gauche.lazy)
; cat
; files ----> port ----> lseq
(define (main args) (let-args (cdr args)
#!/usr/bin/env gosh
; https://gist.github.com/yamasushi/b088d332b6b211a8a01a
(use gauche.parseopt)
(use srfi-13)
(use srfi-14)
(use gauche.lazy)
(use gauche.collection)
(use gauche.sequence)
(use srfi-27)
#!/usr/bin/env gosh
; https://gist.github.com/yamasushi/47c5496ba69eb26d0599
(use srfi-13)
(use srfi-14)
(use gauche.lazy)
(use gauche.collection)
(define cs-kanji #[々〇〻\x3400;-\x9FFF;\xF900;-\xFAFF;\x20000;-\x2FFFF;] )
(define cs-hirakana #[ぁ-ん])
#!/usr/bin/env gosh
; https://gist.github.com/yamasushi/0e6a039ced73d19dcca6
(use gauche.parseopt)
(use gauche.sequence)
(use gauche.lazy)
(use srfi-27)
(define rand (make-random-source))
(random-source-randomize! rand)
#!/usr/bin/env gosh
;https://gist.github.com/yamasushi/4e39c4d5cc3016b469aa
(use gauche.lazy)
(use gauche.parseopt)
(define (main args) (let-args (cdr args)
((nchr "n=i" 140) . files )
($ print
$ list->string