43 lines
984 B
Racket
43 lines
984 B
Racket
|
#lang racket
|
||
|
|
||
|
|
||
|
(define t
|
||
|
|
||
|
|
||
|
(lambda (d)
|
||
|
|
||
|
(define (b d)
|
||
|
(foldl
|
||
|
(lambda (e a)
|
||
|
(cons (cons e (car (car a))) a))
|
||
|
(list (list (list)))
|
||
|
d))
|
||
|
|
||
|
(define (c a)
|
||
|
(foldl
|
||
|
(lambda (e a) (cons e a))
|
||
|
(list)
|
||
|
a))
|
||
|
|
||
|
((lambda (d)
|
||
|
(car (foldl
|
||
|
(lambda (e a)
|
||
|
(if (and (and (char=? (car e) #\e)
|
||
|
(char=? (cdr e) #\r))
|
||
|
(= (car a) -1))
|
||
|
(cons (cdr a) (+ (cdr a) 1))
|
||
|
(cons (car a) (+ (cdr a) 1))))
|
||
|
(cons -1 -1)
|
||
|
(cdr (c (b d))))))
|
||
|
(string->list d) )
|
||
|
)
|
||
|
|
||
|
)
|
||
|
|
||
|
(define l '("red" "sure" "racket" "referendum" "literature" "" "counterexample" "differentiation" "バカ"))
|
||
|
|
||
|
(let loop ((i l))
|
||
|
(when (not (null? i))
|
||
|
(begin
|
||
|
(display (t (car i))) (newline)
|
||
|
(loop (cdr i)))))
|