Yellowstone sequence: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: (Pruned out a redundant language extension))
Line 177: Line 177:
(Plotting tested only on Haskell for Mac).
(Plotting tested only on Haskell for Mac).


<lang haskell>{-# LANGUAGE FlexibleContexts #-}
<lang haskell>import qualified Graphics.SVGFonts.ReadFont as F

module Yellowstone where

import qualified Graphics.SVGFonts.ReadFont as F
import Graphics.Rendering.Chart.Backend.Diagrams
import Graphics.Rendering.Chart.Backend.Diagrams
import Graphics.Rendering.Chart.Easy
import Graphics.Rendering.Chart.Easy
Line 188: Line 184:
import Codec.Picture
import Codec.Picture
import Control.Arrow (second)
import Control.Arrow (second)

------------------YELLOWSTONE PERMUTATION------------------
------------------YELLOWSTONE PERMUTATION------------------
yellowstone :: [Integer]
yellowstone :: [Integer]
Line 202: Line 198:
in (p1, n, residue)
in (p1, n, residue)
active (_, x, _) = x
active (_, x, _) = x

relativelyPrime :: Integer -> Integer -> Bool
relativelyPrime :: Integer -> Integer -> Bool
relativelyPrime a b = 1 == gcd a b
relativelyPrime a b = 1 == gcd a b

----------30 FIRST TERMS, AND CHART OF FIRST 100-----------
----------30 FIRST TERMS, AND CHART OF FIRST 100-----------
main :: IO (Image PixelRGBA8)
main :: IO (Image PixelRGBA8)
Line 214: Line 210:
chartRender env $
chartRender env $
plot (line "Yellowstone terms" [zip [1 ..] (take 100 yellowstone)])
plot (line "Yellowstone terms" [zip [1 ..] (take 100 yellowstone)])

---------------------CHART GENERATION----------------------
---------------------CHART GENERATION----------------------
chartRender
chartRender
Line 223: Line 219:
in renderDia Rasterific (RasterificOptions (mkWidth width)) $
in renderDia Rasterific (RasterificOptions (mkWidth width)) $
fst $ runBackendR env (toRenderable (execEC ec))
fst $ runBackendR env (toRenderable (execEC ec))

------------------------ LOCAL FONT------------------------
------------------------ LOCAL FONT------------------------
chartEnv :: IO (DEnv Double)
chartEnv :: IO (DEnv Double)