lomeo: (лямбда)
Dmitry Antonyuk ([personal profile] lomeo) wrote2011-12-21 06:46 pm

Поиск в ширину

Клёвая реализация сабжа от [livejournal.com profile] antilamer:
data Tree a = Nil | Branch (Tree a) a (Tree a)

bfs t = [x | Branch _ x _ <- b]
  where
    b = t:[x | Branch l _ r <- b, x <- [l,r]]

Ленивость, все дела.

отсюда.

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting