Map range: Difference between revisions
m
→{{header|AppleScript}}: Tidying.
(Map range en BASIC256) |
m (→{{header|AppleScript}}: Tidying.) |
||
Line 116:
=={{header|AppleScript}}==
<lang applescript>--
-- rangeMap :: (Num, Num) -> (Num, Num) -> Num -> Num
on rangeMap(a, b)
script
Line 128 ⟶ 130:
-
on run
set mapping to rangeMap({0, 10}, {-1, 0})
Line 140 ⟶ 142:
-
-- formatted :: Int -> Float -> Ratio -> String
Line 153 ⟶ 155:
--
-- Absolute value.
Line 166:
end if
end abs
-- approxRatio :: Real -> Real -> Ratio
Line 197 ⟶ 198:
end script
end approxRatio
-- enumFromTo :: Int -> Int -> [Int]
Line 210 ⟶ 212:
end if
end enumFromTo
-- gcd :: Int -> Int -> Int
Line 224 ⟶ 227:
return x
end gcd
-- justifyLeft :: Int -> Char -> String -> String
Line 233 ⟶ 237:
end if
end justifyLeft
-- justifyRight :: Int -> Char -> String -> String
Line 242 ⟶ 247:
end if
end justifyRight
-- length :: [a] -> Int
Line 252 ⟶ 258:
end if
end |length|
-- Lift 2nd class handler function into 1st class script wrapper
Line 264 ⟶ 271:
end if
end mReturn
-- map :: (a -> b) -> [a] -> [b]
Line 276 ⟶ 284:
end tell
end map
-- minimum :: Ord a => [a] -> a
Line 288 ⟶ 297:
return m
end minimum
-- ratio :: Int -> Int -> Ratio Int
Line 307 ⟶ 317:
go's |λ|(x * (signum(y)), abs(y))
end ratio
-- Egyptian multiplication - progressively doubling a list, appending
Line 324 ⟶ 335:
return out & dbl
end replicate
-- showRatio :: Ratio -> String
Line 329 ⟶ 341:
(n of r as string) & "/" & (d of r as string)
end showRatio
-- signum :: Num -> Num
Line 340 ⟶ 353:
end if
end signum
-- splitOn :: String -> String -> [String]
Line 349 ⟶ 363:
return xs
end splitOn
-- take :: Int -> [a] -> [a]
Line 381 ⟶ 396:
end if
end take
-- unlines :: [String] -> String
Line 390 ⟶ 406:
str
end unlines
-- zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
|