mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-09 00:11:52 -07:00
X.Prelude: Add takeS
This commit is contained in:
@@ -44,6 +44,7 @@ module XMonad.Prelude (
|
|||||||
Stream(..),
|
Stream(..),
|
||||||
(+~),
|
(+~),
|
||||||
cycleS,
|
cycleS,
|
||||||
|
takeS,
|
||||||
toList,
|
toList,
|
||||||
fromList,
|
fromList,
|
||||||
) where
|
) where
|
||||||
@@ -504,3 +505,8 @@ infixr 5 +~
|
|||||||
-- | Absorb a non-empty list into an infinite stream.
|
-- | Absorb a non-empty list into an infinite stream.
|
||||||
cycleS :: NonEmpty a -> Stream a
|
cycleS :: NonEmpty a -> Stream a
|
||||||
cycleS (x :| xs) = s where s = x :~ xs +~ s
|
cycleS (x :| xs) = s where s = x :~ xs +~ s
|
||||||
|
|
||||||
|
-- | @takeS n stream@ returns the first @n@ elements of @stream@; if @n < 0@,
|
||||||
|
-- this returns the empty list.
|
||||||
|
takeS :: Int -> Stream a -> [a]
|
||||||
|
takeS n = take n . toList
|
||||||
|
Reference in New Issue
Block a user