[ create a new paste ] login | about

johannes

Name: Johannes Hilden
Email:
Site/Blog: http://www.thesyntacticsugar.com
Location:
Default language: Haskell
Favorite languages: C, C++, Haskell
About:

Saved pastes by johannes:

Haskell, pasted on Dec 13:
1
2
3
4
5
module Main where

sine :: Double -> Double
sine x 
  | x < -pi = sine (x + 2*pi)
...
view (17 lines, 20 lines of output)
Python, pasted on Feb 24:
1
print (0.1 + 0.2 == 0.3)
view (1 line, 1 line of output)
Haskell, pasted on Jan 13:
1
2
3
4
5
module Main where

qs :: Ord a => [a] -> [a]
qs [] = []
qs (pivot:xs) = qs lhs ++ pivot : qs rhs
...
view (11 lines, 1 line of output)
C, pasted on Nov 16:
1
2
3
4
5
#include <stdio.h>

static void
qs (int *i, int *j)
{
...
view (198 lines, 1 line of output)
Haskell, pasted on Feb 6:
1
2
3
4
5
module Main where

import Control.Monad.State.Strict

data ManInTown = Customer | SelfShaver | Barber
...
view (43 lines, 2 lines of output)
Haskell, pasted on Feb 5:
1
2
3
4
module Main where

(|>) :: a -> (a -> b) -> b
(|>) = flip ($)
...
view (9 lines, 1 line of output, 1 comment)
Haskell, pasted on Feb 4:
1
2
3
4
module Main where

data Suit = Hearts | Diamonds | Clubs | Spades
    deriving (Show)
...
view (25 lines, 52 lines of output)
Haskell, pasted on Feb 4:
1
2
3
4
5
module Main where

-- [2**x | x <- [1 .. 10], x > 5]
ls = do
    x <- filter (>5) [1 .. 10]
...
view (10 lines, 1 line of output)
Haskell, pasted on Oct 24:
1
2
3
4
module Main where

import Data.List
import Data.Maybe
...
view (16 lines, 1 line of output)
Haskell, pasted on Dec 8:
1
2
3
4
module Main where

x = 0 : y
  where y = 1 : x
...
view (7 lines, 1 line of output)
C, pasted on Dec 7:
1
2
3
4
5
#include <assert.h>
#include <malloc.h>
#include <memory.h>
#include <stdlib.h>
#include <string.h>
...
view (396 lines, 1 line of output, 1 comment)
Haskell, pasted on Nov 9:
1
2
3
4
5
module Main where

import Data.List

-- | Minimally exclusive member of a set (i.e., list)
...
view (14 lines, 1 line of output)
Haskell, pasted on Oct 11:
1
2
3
4
module Main where

import Network.Libev
import Foreign.C.Types
...
view (35 lines, 2 lines of output, 1 comment)
Haskell, pasted on Oct 9:
1
2
3
4
5
{-# LANGUAGE OverloadedStrings #-}

module Url ( Login
           , Url(..)
           , UrlScheme
...
view (140 lines)
Haskell, pasted on Jul 20:
1
2
3
4
5
module Main where

import Data.Foldable as F
import Control.Monad
import Control.Applicative
...
view (15 lines, 1 line of output)
Haskell, pasted on Jul 20:
1
2
3
4
module Main where

import Control.Applicative
import Control.Monad
...
view (15 lines, 1 line of output)
C, pasted on Mar 9:
1
2
3
4
5
#include <stdlib.h>
#include <malloc.h>
#include <assert.h>

#ifndef BOOL
...
view (140 lines, 6 lines of output)
Haskell, pasted on Mar 1:
1
2
3
4
5
module Main where
 
data Pnomial = Pnomial [Int] deriving Show
 
----------------------------------------------------------------
...
view (42 lines, 1 line of output)
Haskell, pasted on Feb 27:
1
2
3
4
module Main where

newt x i n | i == 0    = n
           | otherwise = let f = newt x (pred i) n in (f + x/f) / 2
...
view (6 lines, 1 line of output)
Haskell, pasted on Jan 22:
1
2
3
4
5
module Main where

choose n 0 = 1
choose 0 k = 0
choose n k = choose (n-1) (k-1) * n `div` k 
...
view (9 lines, 1 line of output)
Haskell, pasted on Jan 10:
1
2
3
4
5
module Main where

import Data.List

insort :: (Ord a) => [a] -> [a]
...
view (10 lines, 1 line of output)
C, pasted on Jan 10:
1
2
3
4
5
void insertion_sort(int *n, size_t s)
{
   int *i, *j, *top, t;
   i = n;
   top = n + s - 1;
...
view (33 lines, 11 lines of output)
C++, pasted on Nov 8:
1
2
3
4
5
#include <iostream.h>
#include <boost/scoped_array.hpp>

void reverse(char *str, unsigned int n)
{
...
view (35 lines, 1 line of output)
C++, pasted on Nov 8:
1
2
3
4
5
#include <iostream.h>
#include <boost/scoped_array.hpp>

void reverse(char *str, unsigned int n)
{
...
view (33 lines, 1 line of output)
C++, pasted on Nov 8:
1
2
3
4
5
#include <iostream.h>

void reverse(char *str, unsigned int n)
{
    if (n < 2) return;
...
view (33 lines, 1 line of output)
C++, pasted on Nov 2:
1
2
3
4
5
#include <iostream>

int main()
{
    int *p[2];
...
view (27 lines, 4 lines of output)
C++, pasted on Nov 2:
1
2
3
4
5
#include <iostream>
#include <assert.h>

static int five = 5;
static int nine = 9;
...
view (63 lines, 6 lines of output)
C++, pasted on Nov 2:
1
2
3
4
5
class SomeClass
{
public:
    void func1(int x) const { std::cout << "calling func 1 with arg. " << x << std::endl; }
    void func2(int x) const { std::cout << "calling func 2 with arg. " << x << std::endl; }
...
view (21 lines, 1 line of output)
C++, pasted on Nov 2:
1
2
3
4
5
#include <iostream>

int takeThisInt()
{
    return 123;
...
view (14 lines, 1 line of output)
C++, pasted on Nov 2:
1
2
3
4
5
#include <iostream>

int main()
{
    int n[2];
...
view (20 lines, 4 lines of output)
C++, pasted on Nov 2:
1
2
3
4
5
#include <iostream>

int main()
{
    int *p[2];
...
view (22 lines, 2 lines of output)
C++, pasted on Sep 27:
1
2
3
4
5
class A
{
public:
    A(const char *info)
        : m_info(new std::string(info))
...
view (66 lines, 2 lines of output)
C++, pasted on Sep 27:
1
2
3
4
5
class A
{
public:
    A(const char *info)
        : m_info(new std::string(info))
...
view (60 lines, 23 lines of output)
C++, pasted on Sep 27:
1
2
3
4
5
#include <boost/shared_ptr.hpp>
 
class SmartPimplPrivate
{
public:
...
view (66 lines, 7 lines of output)
C++, pasted on Sep 27:
1
2
3
4
5
class PimplPrivate
{
public:
    PimplPrivate()
        : count(1)
...
view (83 lines, 4 lines of output)
C++, pasted on Sep 27:
1
2
3
4
5
class Stuff
{
public:
    Stuff()
        : m_count(new long unsigned),
...
view (84 lines, 6 lines of output)
C++, pasted on Sep 27:
1
2
3
4
5
class Stuff
{
public:
    Stuff()
        : m_count(new long unsigned),
...
view (85 lines, 8 lines of output)
C++, pasted on Sep 15:
1
2
3
4
5
#include <boost/shared_ptr.hpp>

class Stuff
{
public:
...
view (28 lines, 1 line of output)
C++, pasted on Sep 15:
1
2
3
4
5
class Stuff
{
public:
    Stuff() {}
    ~Stuff() {}
...
view (24 lines, 2 lines of output)
C++, pasted on Sep 7:
1
2
3
4
5
class K
{
public:
    K() {}
    ~K() {}
...
view (26 lines, 2 lines of output)
C++, pasted on Aug 31:
1
2
3
4
5
class Fruit
{
public:
    Fruit()
        : m_color("fruit-colored"),
...
view (70 lines, 4 lines of output)
C++, pasted on Aug 29:
1
2
3
4
5
#include <iostream.h>

class Base
{
public:
...
view (53 lines, 4 lines of output)
Haskell, pasted on Aug 7:
1
2
3
4
module Main where

fn3 f = \x -> \y -> if (y == 0) then x else f y (rem x y)
fpc f = f (fpc f)
...
view (8 lines, 1 line of output)
Haskell, pasted on Aug 7:
1
2
3
4
module Main where

fn2 f = \x -> if (x == 0 || x == 1) then x else f (x-1) + f (x-2)
fpc f = f (fpc f)
...
view (8 lines, 1 line of output)
Haskell, pasted on Aug 7:
1
2
3
4
5
module Main where

fn f = \x -> if (x == 0) then 1 else x * f (x - 1)

fpc f = f (fpc f)
...
view (8 lines, 1 line of output)
Haskell, pasted on Aug 7:
1
2
3
4
5
module Main where

doubled (x:xs) = x+x : doubled xs
numbers = [1..]
doubledNumbers = doubled numbers
...
view (7 lines, 1 line of output)
Haskell, pasted on Aug 7:
1
2
3
4
5
module Main where

n = [1..]

main = print (n!!8)
view (5 lines, 1 line of output)
Haskell, pasted on Aug 7:
1
2
3
4
module Main where

fn x = "lazy"
n = n
...
view (6 lines, 1 line of output)
Haskell, pasted on Aug 7:
1
2
3
4
module Main where

f x = 1
x = f x
...
view (6 lines, 1 line of output)
Haskell, pasted on Aug 7:
1
2
3
4
module Main where

f fx = \n -> 5
x = f x
...
view (6 lines, 1 line of output)
Haskell, pasted on Aug 7:
1
2
3
4
5
module Main where

n = 5 : n

main = print (take 3 n)
view (5 lines, 1 line of output)
Haskell, pasted on Aug 4:
1
2
3
4
5
module Main where

zero = \f -> \x -> x
one  = \f -> \x -> f x
two  = \f -> \x -> f (f x)
...
view (8 lines, 1 line of output)
Haskell, pasted on Aug 3:
1
2
3
4
module Main where

fn x = "lazy"
numbers = [1..]             -- a list of integers 1 to ∞
...
view (6 lines, 1 line of output)
Haskell, pasted on Aug 3:
1
2
3
4
module Main where

fn1 x = "lazy"
fn2 = [1..]
...
view (6 lines, 1 line of output)
C++, pasted on Aug 2:
1
2
3
4
5
#include <iostream.h>

void count(int n)
{
    std::cout << "Counting: " << n << "\n";
...
view (15 lines, 5 lines of output)
Haskell, pasted on Aug 2:
1
2
3
module Main where

main = print ("hello")
view (3 lines, 1 line of output)