Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Dynamic language

Name: Anonymous 2012-11-06 4:54

http://ro-che.info/ccc/images/typing.png

When do you ever need dynamism? When do you ever need monkey-patching, eval, heterogeneous collections, and shit like this?

Name: Anonymous 2012-11-06 6:57

When do you ever need dynamism?

Symta:

f !?.??+1 [ø@X]


Haskell:

module Main
where

import List
import Control.Arrow

type Comparator a = (a -> a -> Ordering)

ascending :: (Ord a) => (b -> a) -> Comparator b
ascending f x y = compare (f x) (f y)

descending :: (Ord a) => (b -> a) -> Comparator b
descending = flip . ascending

secondary :: Comparator a -> Comparator a -> Comparator a
secondary f g x y = case f x y of {
                    EQ -> g x y;
                    z  -> z; }

-- Returns a list of unique elements together with their frequency. Listed in decreasing order of frequency, followed by
increasing order of the elements.
count :: (Ord a) => [a] -> [(a, Int)]
count = map (head &&& length) . sortBy (descending length `secondary` ascending head) . group . sort

main :: IO ()
main = interact $ unlines . map (\(x, y) -> (take 20 $ x ++ repeat ' ')  ++ " : " ++ show y) . count . words

Name: Anonymous 2012-11-06 7:00

>>6

f ø !?.??+1 X


self fix.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List