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

ITT the ABC Programming Language

Name: Anonymous 2008-07-29 19:29

#include <stdio.h>

int main(int argc,char argv*[]){
  int i = 0;
  int BUFFA;

  while(argv[i]!='\0'){
    if(argv[i]='a')
      BUFFA++;
    else if(argv[i]='b')
      BUFFA--;
    else if(argv[i]='c')
      printf("%i\n",BUFFA);
    else printf("%s","Error.\n");
  }
}

Name: Anonymous 2008-08-01 15:16


abc :: [Char] -> IO ()
abc = abc' 0

abc' :: Int -> [Char] -> IO ()
abc' n (x:xs) =
    case x of
      'a' -> abc' (n+1) xs
      'b' -> abc' (n-1) xs
      'c' -> ((putChar.toEnum) n >> abc' n xs)
      _ -> abc' n xs
abc' _ _ = putStrLn ""

gen :: [Char] -> [Char]
gen = gen' 0

gen' :: Int -> [Char] -> [Char]
gen' n (x:xs) =
    let
        c = fromEnum x
        abc | (c > n) = take (c-n) $ repeat 'a'
            | (c < n) = take (n-c) $ repeat 'b'
            | c == n  = ""
    in
      abc ++ ('c' : gen' c xs)
gen' _ _ = ""


It looks like fucking sepples, but I'm too tired to improve it

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