lomeo: (лямбда)
[personal profile] lomeo
Клёвая реализация сабжа от [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]]

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

отсюда.

Date: 2011-12-21 05:13 pm (UTC)
From: [identity profile] lomeo.livejournal.com
Например
bfs t = [x | Branch _ x _ <- b [t]]
  where
    b [] = []
    b ts = ts ++ b [x | Branch l _ r <- ts, x <- [l,r]]

Profile

lomeo: (Default)
Dmitry Antonyuk

April 2024

S M T W T F S
 123456
7891011 1213
14151617181920
21222324252627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 20th, 2025 05:07 pm
Powered by Dreamwidth Studios