1. Куча / Говнокод #12096

    +125

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    happy_numbers = [ tos (a,b,c,d,e,f a b c d e) | a <- [0..9], b <- [0..9], c <- [0..9], d <- [0..9], e <- [0..9], f a b c d e <= 9, f a b c d e >= 0 ]
    	where 
    		tos (a,b,c,d,e,f) = show a ++ show b ++ show c ++ show d ++ show e ++ show f
    		f a b c d e = a + b + c - d - e
    
    main = mapM print $ happy_numbers

    Fai, 11 Ноября 2012

    Комментарии (52)
  2. Куча / Говнокод #12090

    +120

    1. 1
    clearScreen = putStr $ take 50 (repeat '\n')

    Написано нормально, но вот задумка...

    Fai, 10 Ноября 2012

    Комментарии (26)
  3. Куча / Говнокод #12085

    +124

    1. 1
    2. 2
    3. 3
    4. 4
    main =do
            let b = 56
            let b = b+1
            print b

    Зачем есть возможность задавать переменные с однаковыми именами, если их использовать ниже всё равно нельзя?
    http://ideone.com/b1DGYF

    LispGovno, 09 Ноября 2012

    Комментарии (26)
  4. Куча / Говнокод #12083

    +124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    data Trivalent = TriFalse | TriUnknown | TriTrue deriving (Show, Eq, Ord)
    
    (&) :: Trivalent -> Trivalent -> Trivalent -- &&
    (!) :: Trivalent -> Trivalent -> Trivalent -- ||
    nt :: Trivalent -> Trivalent -- not

    В хасскеле нет класса для логических значений. А значит хрен переопределишь операторы &&, || и функцию not

    Fai, 08 Ноября 2012

    Комментарии (52)
  5. Куча / Говнокод #12075

    +119

    1. 1
    2. 2
    3. 3
    4. 4
    data Fuuu = Fuuu
    instance Eq Fuuu
     
    main = print $ if Fuuu == Fuuu then "I dosen't seen this" else "and this"

    Вот за что мне нравится сверх надежный высокоуровневый хаскель, так за то, что если забыл переопределить какой-то метод или оператор из класа типов (в нормальных языках это интерфейс или один из базовых класов) стандартной библиотеки языка или неподходящим образом от него отнаследовался, то мы получаем надежное поведение:
    http://ideone.com/6faPct
    результат: Ошибка выполнения время: 0.01s память: 3580 kB сигнал: -1
    ввод: нет
    вывод: нет
    stderr:
    prog: <<loop>>

    HaskellGovno, 07 Ноября 2012

    Комментарии (19)
  6. Куча / Говнокод #12074

    +126

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    infixr 6 `then'`
    then' True = fst
    then' False = snd
    if' = id
    else' suc fail = (suc, fail)
    main = do
        print $ if' (1<5) `then'` "true" `else'` "false"
        print $ if' False `then'` "true" `else'` "false"

    bormand
    У ифа особый синтаксис. Как ты его реализуешь?
    Challenge accepted:
    Сначала был тред
    http://govnokod.ru/12068#comment159236
    а потом родилось говно:
    http://ideone.com/rOKDPP
    Реализовал if. За правильными приоритетами операций и ассоциативностью не следил.

    HaskellGovno, 07 Ноября 2012

    Комментарии (23)
  7. Куча / Говнокод #12068

    +129

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    -- Подготовка
    (.-) :: ot -> (ot -> rt) -> rt
    object .- method = method object
    
    to_string () self = show self
    
    my_array = [1..]
    
    -- ООП в действии
    main = putStrLn( my_array.-take(10).-drop(5).-to_string() )

    Хаскелл и ООП.

    Fai, 07 Ноября 2012

    Комментарии (31)
  8. Куча / Говнокод #12052

    +142

    1. 1
    http://s9.postimage.org/7t1dai0en/born_to_program.png

    Born to program :(

    wvxvw, 04 Ноября 2012

    Комментарии (10)
  9. Куча / Говнокод #12050

    +136

    1. 1
    2. 2
    3. 3
    <!--[if lte IE 6]>
    Ваш браузер говно. Качайте новый...
    <![endif]-->

    Верстальщику респект...

    BaranOnGovnokod, 03 Ноября 2012

    Комментарии (122)
  10. Куча / Говнокод #12049

    +122

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    data IdPState a r = IdPEnd r | IdPNeedInput | IdPHaveInput a
    {-# INLINE_STREAM idP #-}
    idP :: (Monad m) => Stream l a a r m r
    idP = Stream next IdPNeedInput where
    	{-# INLINE_INNER next #-}
    	next (IdPEnd r) = Done r
    	next IdPNeedInput = NeedInput IdPHaveInput IdPEnd
    	next (IdPHaveInput a) = HaveOutput IdPNeedInput (return ()) a
    
    {-# INLINE_STREAM pipe #-}
    pipe :: Monad m => Stream l a b r0 m r1 -> Stream Void b c r1 m r2 -> Stream l a c r0 m r2
    pipe (Stream nextL sL) (Stream nextR sR) = Stream next (Right (return (), sL, Right sR)) where
    	{-# INLINE_INNER next #-}
    	next (Left r) = Done r
    	next (Right (final, sL, Right sR)) = case nextR sR of
    		Skip sR' -> Skip (Right (final, sL, Right sR'))
    		HaveOutput sR' c o -> HaveOutput (Right (final, sL, Right sR')) (c >> final) o
    		NeedInput p c -> Skip (Right (final, sL, Left (p, c)))
    		Done r -> PipeM (final >> return (Left r))
    		PipeM ms -> PipeM (liftM (Right . (final, sL,) . Right) ms)
    		Leftover _ i -> absurd i
    	next (Right (final, sL, Left (p, c))) = case nextL sL of
    		Skip sL' -> Skip (Right (final, sL', Left (p, c)))
    		HaveOutput sL' final' o -> Skip (Right (final', sL', Right (p o)))
    		NeedInput pL cL -> NeedInput (Right . (final,, Left (p, c)) . pL) (Right . (final,, Left (p, c)) . cL)
    		Done r -> Skip (Right (return (), sL, Right (c r)))
    		PipeM ms -> PipeM (liftM (Right . (final,, Left (p, c))) ms)
    		Leftover sL' i -> Leftover (Right (final, sL', Left (p, c))) i
    
    {-# INLINE_STREAM purePipe #-}
    purePipe :: (forall m . Monad m => Stream l a b r0 m r1) -> (forall m . Monad m => Stream Void b c r1 m r2) -> (forall m . Monad m => Stream l a c r0 m r2)
    purePipe (Stream nextL sL) (Stream nextR sR) = Stream next (sL, Right sR) where
    	{-# INLINE_INNER next #-}
    	next (sL, Right sR) = case nextR sR of
    		Skip sR' -> Skip (sL, Right sR')
    		HaveOutput sR' _ o -> HaveOutput (sL, Right sR') (return ()) o
    		NeedInput p c -> Skip (sL, Left (p, c))
    		Done r -> Done r
    		PipeM ms -> Skip (sL, Right (runIdentity ms))
    		Leftover _ i -> absurd i
    	next (sL, Left (p, c)) = case nextL sL of
    		Skip sL' -> Skip (sL', Left (p, c))
    		HaveOutput sL' _ o -> Skip (sL', Right (p o))
    		NeedInput pL cL -> NeedInput ((, Left (p, c)) . pL) ((, Left (p, c)) . cL)
    		Done r -> Skip (sL, Right (c r))
    		PipeM ms -> Skip (runIdentity ms, Left (p, c))
    		Leftover sL' i -> Leftover (sL', Left (p, c)) i

    qbasic, 03 Ноября 2012

    Комментарии (23)