Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,5 @@
import Data.List
import Control.Monad
import Control.Arrow
doWhile p f n = (n:) $ takeWhile p $ unfoldr (Just.(id &&& f)) $ succ n

View file

@ -0,0 +1,7 @@
*Main> mapM_ print $ doWhile ((/=0).(`mod`6)) succ 0
0
1
2
3
4
5

View file

@ -0,0 +1,7 @@
main :: IO ()
main =
mapM_ print . reverse $
until
(\(x:_) -> (x > 0) && (mod x 6 == 0))
(\xs@(x:_) -> succ x : xs)
[0]

View file

@ -0,0 +1,10 @@
import Data.IORef
import Control.Monad.Loops
main = do
x <- newIORef 0;
iterateWhile (\val -> val `mod` 6 /= 0 ) $ do
modifyIORef x (+1)
val <- readIORef x
print val
return val