let it leave me like a long breath

let it dissipate or fade in the background

Oct. 13th, 2015

Profile

xax: purple-orange {11/3 knotwork star, pointed down (Default)
howling howling howling

Nav

  • Recent Entries
  • Archive
  • Reading
  • Tags
  • Memories
  • Profile

Tags

  • art - 2 uses
  • asteroid garden - 4 uses
  • code - 19 uses
  • demos - 1 use
  • dreams - 5 uses
  • ff7 fangame - 23 uses
  • fic prompts - 13 uses
  • gamedev challenge - 82 uses
  • hell game - 76 uses
  • nanowrimo - 11 uses
  • plants - 9 uses
  • process - 52 uses
  • programming - 51 uses
  • screenshots - 5 uses
  • writing log - 83 uses

May 2025

S M T W T F S
    123
45678 910
1112131415 1617
18192021222324
25262728293031
    • Previous Day
    • |
    • Next Day

    Oct. 13th, 2015

  • xax: purple-orange {11/3 knotwork star, pointed down (Default)
    • Current Music: Coheed and Cambria - The Willing Well I: Fuel for the Feeding End
    Tags:
    • programming
    posted @ 07:18 pm

    tiltRandomly :: (a, a) -> Plane a -> Rand g (Plane a)
    tiltRandomly (lo, hi) p =
      if (lo > hi)
        then error "tiltRandomly: lo > hi"
        else case (listToMaybe . liftM catMaybes . sequence . repeat $ do
          v <- V2 <$> randomR (0, hi) <*> randomR (0, hi)
          if magnitude v <= hi && magnitude v >= lo
            then $ Just v
            else Nothing) of
          Just v -> return $ tilt v p
          Nothing -> error "tiltRandomly: uh wow that infinite list sure evaluated fast huh"
    
    

    i think this is the first time i've explicitly used laziness to my advantage

    but of course it's in a messy partial function. also, bad news if you set lo & hi such that it takes like eight million tries to get a value that passes! laziness sure is a thing.


    • Add Memory
    • Share This Entry
    • Link
    • 0 comments
    • Reply
    • Previous Day
    • |
    • Next Day
Page generated Oct. 16th, 2025 11:25 pm
Powered by Dreamwidth Studios

Style Credit

  • Style: (No Theme) for vertical