This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; お題:文字列を先頭から見て同じところまで除去 - No Programming, No Life | |
;; http://d.hatena.ne.jp/fumokmm/20110812/1313138407 | |
(use srfi-13) | |
(define (remove-string-prefix . strs) | |
(and (not (null? strs)) | |
(map (cut string-drop <> | |
(apply min | |
(map (pa$ string-prefix-length (car strs)) | |
strs))) | |
strs))) | |
(remove-string-prefix "abcdef" "abc123") | |
;; -> ("def" "123") | |
(remove-string-prefix "あいうえお" "あいさんさん" "あいどる") | |
;; -> ("うえお" "さんさん" "どる") | |
(remove-string-prefix "12345" "67890" "12abc") | |
;; -> ("12345" "67890" "12abc") |
結果的にこちら↓とほぼ同じになりました。
0 件のコメント:
コメントを投稿