Yellowstone sequence: Difference between revisions

m
→‎{{header|Haskell}}: Used Data.Bifunctor in place of Control.Arrow
(→‎{{header|Wren}}: Now uses Wren-math module.)
m (→‎{{header|Haskell}}: Used Data.Bifunctor in place of Control.Arrow)
Line 215:
 
A variation on the definition of the Yellowstone permutation (in terms of '''iterate''', as an alternative to '''unfoldr'''), and a basic chart of the first 100 terms.
(Plotting tested only on Haskell for Mac).
 
<lang haskell>import qualified Graphics.SVGFonts.ReadFont as F
Line 223 ⟶ 222:
import Diagrams.Prelude
import Codec.Picture
import ControlData.ArrowBifunctor (second)
 
------------------YELLOWSTONE PERMUTATION------------------
 
yellowstone :: [Integer]
yellowstone = 1 : 2 : (active <$> iterate nextWindow (2, 3, [4 ..]))
Line 241:
relativelyPrime :: Integer -> Integer -> Bool
relativelyPrime a b = 1 == gcd a b
 
 
----------30 FIRST TERMS, AND CHART OF FIRST 100-----------
 
main :: IO (Image PixelRGBA8)
main = do
Line 250 ⟶ 252:
chartRender env $
plot (line "Yellowstone terms" [zip [1 ..] (take 100 yellowstone)])
 
 
 
---------------------CHART GENERATION----------------------
Line 256 ⟶ 260:
=> DEnv Double -> EC r () -> Image PixelRGBA8
chartRender env ec =
letrenderDia Rasterific (width,RasterificOptions _)(mkWidth =(fst (envOutputSize env)))) $
fst $ runBackendR env (toRenderable (execEC ec))
in renderDia Rasterific (RasterificOptions (mkWidth width)) $
fst $ runBackendR env (toRenderable (execEC ec))
 
------------------------ LOCAL FONT------------------------
9,659

edits