1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

進捗どうですかブームに乗り遅れてみる

Last updated at Posted at 2015-07-19

gaucheで。
scheme初心者なのでもうちょい色々な実装見てみたいなぁ(チラ

(use util.queue)
(use math.mt-random)
(define mt (make <mersenne-twister> :seed (sys-time)))

(define (doudesuka? arr-src)
  (define (get-one lst)
    (let loop ((c (mt-random-integer mt 4)) (arr lst))
      (if (= c 0)
          (car arr)
          (loop (- c 1) (cdr arr)))))
  (define q (list->queue (list (get-one arr-src)
                               (get-one arr-src)
                               (get-one arr-src)
                               (get-one arr-src))))
  (let loop ((d "") (sum-chars 0) (chk-lst q))
    (if (equal? (queue->list q) arr-src)
        (begin
          (map (lambda (x) (set! sum-chars (+ sum-chars (string-length x)))) arr-src)
          (map (lambda (x) (display x)) (queue->list q))
          (newline)
          (print sum-chars "文字で煽られました。" arr-src "!!!"))
        (begin
          (display (set! d (dequeue! q)))
          (loop d (+ sum-chars (string-length d)) (enqueue! q (get-one arr-src)))
          ))))

(doudesuka? '("進捗" "どう" "です" "か"))

進捗進捗進捗進捗どう進捗どうですどうどうどうどうです進捗ですですどうかどう進捗か進捗か進捗かかか進捗進捗かかどうですかですかどうですどうかですどう進捗進捗かどう進捗ですか進捗ですですかどう進捗ですですかです進捗進捗か進捗か進捗か進捗どう進捗です進捗進捗です進捗ですかかどうどう進捗か進捗どう進捗ですどう進捗か進捗進捗ですどう進捗かどうどうどう進捗どうですか
178文字で煽られました。(進捗 どう です か)!!!

1
1
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?