[ create a new paste ] login | about

uskz

Name:
Email:
Site/Blog: http://d.hatena.ne.jp/uskz/
Location:
Default language:
Favorite languages: C++
About:

Saved pastes by uskz:

Haskell, pasted on Apr 24:
1
2
3
4
5
data ListL a = Nil | Snoc (ListL a, a) deriving Show
data Tree a = Tip a | Bin (Tree a, Tree a) deriving Show
data GTree a = Node (a, ListL (GTree a)) deriving Show

foldL (c, h) Nil = c
...
view (50 lines, 1 line of output)
Haskell, pasted on Apr 19:
1
2
3
4
foldN f e 0 = e
foldN f e (n + 1) = f $ foldN f e n

fib = fst . foldN (\ (m, n) -> (n, m + n)) (0, 1)
...
view (6 lines, 1 line of output)
Haskell, pasted on Apr 19:
1
2
3
4
foldN e f 0 = e
foldN e f (n + 1) = f $ foldN e f n

fib = fst . foldN (0, 1) (\ (m, n) -> (n, m + n))
...
view (6 lines, 1 line of output)
Haskell, pasted on Feb 25:
1
2
3
4
5
import Prelude hiding (drop)

cond p f g x = if p x then f x else g x 

drop :: Int -> [a] -> [a]
...
view (8 lines, 1 line of output)
Haskell, pasted on Feb 25:
1
2
3
4
5
cond p f g x = if p x then f x else g x 

take' = flip $ foldr (\x f -> (cond (>0) ((x:).f.pred) (const []))) (const [])

main = print $ take' 2 [1, 2, 3]
view (5 lines, 1 line of output)
Haskell, pasted on May 21:
1
2
3
4
foldN e f 0 = e
foldN e f (n + 1) = f $ foldN e f n

fib = fst . foldN (0, 1) (\ (m, n) -> (n, m + n))
...
view (6 lines, 1 line of output)
Haskell, pasted on May 21:
1
2
3
4
fib = fst . fib'
      where
          fib' 0 = (0, 1)
          fib' (n + 1) = (b, a + b)
...
view (8 lines, 1 line of output)
C++, pasted on May 21:
1
2
3
4
5
#include <cstdlib>
#include <iostream>

struct Hello
{
...
view (11 lines, 1 line of output)
C++, pasted on Mar 24:
1
2
3
4
5
#include <iostream>
#include <boost/typeof/typeof.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
...
view (30 lines, 1 line of output)
C++, pasted on Mar 23:
1
2
3
4
5
#include <algorithm>
#include <iostream>
#include <string>
#include <boost/function.hpp>
#include <boost/scoped_ptr.hpp>
...
view (57 lines, 3 lines of output)
C++, pasted on Feb 14:
1
2
3
4
5
#include <iostream>
#include <boost/foreach.hpp>

int main()
{
...
view (10 lines, 6 lines of output)
C++, pasted on Feb 12:
1
2
3
4
5
#include <iostream>
#include <boost/function.hpp>
#include <boost/lambda/lambda.hpp>

int main()
...
view (18 lines, 3 lines of output)
C++, pasted on Feb 12:
1
2
3
4
5
#include <boost/utility/result_of.hpp>

template <class F>
struct X 
{
...
view (22 lines)
C++, pasted on Feb 2:
1
2
3
4
5
#include <iostream>

struct base
{
    void f() const
...
view (32 lines)
C++, pasted on Jan 12:
1
2
3
4
5
#include <iostream>

struct null
{
    struct executor
...
view (61 lines, 1 line of output)
C++, pasted on Jan 12:
1
2
3
4
5
#include <iostream>

struct null
{
    struct execute_
...
view (61 lines, 1 line of output)
Haskell, pasted on Dec 15:
1
2
3
4
5
cnat n f x = iterate f x !! n
           = (!!n) (iterate f x)
           = (!!n) ((iterate f) x)
           = ((!!n).(iterate f)) x
           = (((!!n).) (iterate f)) x
...
view (9 lines)
Ruby, pasted on Nov 29:
1
printf("%d", 5-----3)
view (1 line, 1 line of output)
C++, pasted on Oct 21:
1
2
3
4
#include <iostream>
#include <boost/version.hpp>

int main()
...
view (9 lines, 2 lines of output)
C++, pasted on Oct 6:
1
2
3
4
#define o

int main()
{
...
view (10 lines)
C++, pasted on Sep 30:
1
2
3
4
5
#include <iostream>
#include <boost/preprocessor/control/if.hpp>
#include <boost/preprocessor/comparison/equal.hpp>
#include <boost/preprocessor/arithmetic/mod.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
...
view (23 lines, 50 lines of output)
C++, pasted on Sep 25:
1
2
3
4
5
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <boost/lambda/lambda.hpp>
...
view (35 lines, 1 line of output)
C++, pasted on Aug 11:
1
2
3
4
5
#include <iostream>

template <class T>
struct outer
{
...
view (48 lines, 3 lines of output)
C++, pasted on Aug 10:
1
2
3
4
5
#include <iostream>

int fact(int n, int a = 1)
{
    return n == 0 ? a
...
view (12 lines, 1 line of output)
C++, pasted on Jul 29:
1
2
3
4
5
#include <iostream>

template <class F>
struct repeater
{
...
view (40 lines, 3 lines of output)
Haskell, pasted on Jun 12:
1
2
3
4
5
import Control.Arrow
import Prelude hiding (not, and, or, Bool)

unit :: (a, ()) -> a
unit (x, ()) = x
...
view (39 lines, 1 line of output)
PHP, pasted on Sep 5:
1
2
3
4
<?
for($i = 1; $i <= 100; $i++)
  echo $i % 15 != 0 ? $i % 5 != 0 ? $i % 3 != 0 ? $i."\n" : "Fizz\n" : "Buzz\n" : "FizzBuzz\n";
?>
view (4 lines, 100 lines of output)
C++, pasted on Sep 3:
1
2
3
4
5
#include <iostream>

struct foo_
{
    template <class T, class A>
...
view (16 lines, 1 comment)
Perl, pasted on Aug 26:
1
2
3
4
5
#!/bin/perl

{
  my @a = ([1, 2, 3, 4], [5, 6, 7, 8]);
  $a[2] = [9, 10];
...
view (8 lines, 1 line of output)
Perl, pasted on Aug 26:
1
2
3
4
5
#!/bin/perl

{
  my @a = (1, 2, 3, 4);
  my @b = (5, 6, 7, 8);
...
view (13 lines, 1 line of output)
Perl, pasted on Aug 26:
1
2
3
4
5
#!/bin/perl

{
my @a = (1, 2, 3, 4);
my @b = (5, 6, 7, 8);
...
view (13 lines, 1 line of output)