Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import Data.List (minimumBy, tails, unfoldr, foldl1') --'
import System.Random (newStdGen, randomRs)
import Control.Arrow ((&&&))
import Data.Ord (comparing)
vecLeng [[a, b], [p, q]] = sqrt $ (a - p) ^ 2 + (b - q) ^ 2
findClosestPair =
foldl1'' ((minimumBy (comparing vecLeng) .) . (. return) . (:)) .
concatMap (\(x:xs) -> map ((x :) . return) xs) . init . tails
testCP = do
g <- newStdGen
let pts :: [[Double]]
pts = take 1000 . unfoldr (Just . splitAt 2) $ randomRs (-1, 1) g
print . (id &&& vecLeng) . findClosestPair $ pts
main = testCP
foldl1'' = foldl1'

View file

@ -0,0 +1,3 @@
*Main> testCP
([[0.8347201880148426,0.40774840545089647],[0.8348731214261784,0.4087113189531284]],9.749825850154334e-4)
(4.02 secs, 488869056 bytes)