Talk:ABC problem: Difference between revisions
Content added Content deleted
(→Alternative Common Lisp version: new section) |
|||
Line 131: | Line 131: | ||
I think this is a little bit more consice (at least it is definitely shorter). I'm not sure about adding it in addition to the old one / instead? |
I think this is a little bit more consice (at least it is definitely shorter). I'm not sure about adding it in addition to the old one / instead? |
||
<code> |
<code> |
||
(defun word-possible-p (word alphabet) |
(defun word-possible-p (word alphabet) |
||
(labels ((% |
(labels ((%first-or-second (b) |
||
(find (char-upcase (char word 0)) b))) |
(find (char-upcase (char word 0)) b))) |
||
(or (zerop (length word)) |
(or (zerop (length word)) |
||
(iter |
(iter |
||
(for candidate :in (remove-if-not #'% |
(for candidate :in (remove-if-not #'%first-or-second alphabet)) |
||
(when (word-possible-p |
(when (word-possible-p |
||
(subseq word 1) (remove candidate alphabet :count 1)) |
(subseq word 1) (remove candidate alphabet :count 1)) |
||
(return t)))))) |
(return t)))))) |
||
</code> |
</code> |
||
[[User:Wvxvw|Wvxvw]] ([[User talk:Wvxvw|talk]]) 13:37, 5 April 2015 (UTC) |
[[User:Wvxvw|Wvxvw]] ([[User talk:Wvxvw|talk]]) 13:37, 5 April 2015 (UTC) |