You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made this prototype via GPT (stopPrinting doesn't work!):
importData.Fixed (mod')
importText.Printf (printf)
importControl.ConcurrentimportControl.Monad (forever, when)
streamGetnowMods::Double->Stream->IO [Double]
streamGetnowMods mod s =dolet mods =take6$iterate (*2) mod
result <- streamGetnow s
return$!map (mod' result) mods
streamGetnowModsString::Double->Stream->IOString
streamGetnowModsString mod s =dolet mods =take6$iterate (*2) mod
results <- streamGetnowMods mod s
cyclePos <- streamGetnow s
let formattedResults = printf "%.0f: " cyclePos :zipWith (\x y -> printf "%d/%.0f" (floor x +1) y) results mods
return$unwords formattedResults
printEverySecond::Double->Stream->IO()
printEverySecond mod s = forever $do
result <- streamGetnowModsString mod s
cps <- streamGetcps s
let delay =floor (1/ cps *1000000) -- convert cps to microsecondsputStrLn result
threadDelay delay
startPrinting::Double->Stream->IO (MVar())
startPrinting mod s =do
stopVar <- newEmptyMVar
_ <- forkIO $dolet loop =do
stopped <- tryTakeMVar stopVar
Control.Monad.when (stopped ==Nothing) $do
printEverySecond mod s
loop
loop
return stopVar
stopPrinting::MVar()->IO()
stopPrinting stopVar =do
putMVar stopVar ()return()
I made this prototype via GPT (
stopPrinting
doesn't work!):It prints out a status line like this:
I made this to help with composition and performance, makes it easier to keep track of things. Note that you don't have to use 4 as the base.
Would be cool to integrate this into an editor as feedback. I don't really know how to do that so just posting here for now!
The text was updated successfully, but these errors were encountered: