|
codepad
|
|
|
Saved pastes by jleedev:
import List(genericReplicate)
fibs=1:1:zipWith(+)fibs(tail fibs)
ggg=map(`genericReplicate`'g')fibs
main=mapM_ putStrLn ggg
|
view (4 lines, 22 lines of output) |
u = ''.join(map(unichr, [1505, 1500, 1511, 1493, 1501]))
s = u.encode('utf-8')
print s.decode('cp1255', 'replace').encode('utf-8')
|
view (3 lines, 1 line of output) |
qux=map('q':)ux
u:ux=iterate('u':)"x"
vars="foo":"bar":"baz":qux
p(v:ars)=putStrLn v>>p ars
main=p vars
|
view (5 lines, 234 lines of output) |
require 'digest/sha1'
sha1 = ['e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'].pack 'H*'
contents = "100644 a.txt\0#{sha1}100644 b.txt\0#{sha1}"
data = "tree #{contents.length}\0#{contents}"
p Digest::SHA1.hexdigest(data)
|
view (5 lines, 1 line of output) |
[:zero?, :one?, :two?, :three?, :four?, :five?].each_with_index do |x,i|
Integer.send(:define_method, x) { self == i }
end
p 0.zero?
|
view (7 lines, 3 lines of output) |
# You can use the yield statement to create a generator...
def iter_function():
yield 'hello'
yield 'world'
|
view (40 lines, 7 lines of output) |
import Char (intToDigit)
import Numeric (showIntAtBase)
import Data.Word
cletus :: Word8 -> Word8
|
view (16 lines, 32 lines of output) |
import List
import Control.Monad
import Control.Arrow
collatz 1 = Nothing
collatz n = Just . join (,) $ if even n
|
view (8 lines, 2306 lines of output) |
data N = Z | S N deriving (Ord,Eq,Show)
instance Num N where
x + Z = x
x + (S y) = S (x + y)
fromInteger 0 = Z
|
view (9 lines, 1 line of output) |
-- I <3 Cale
import Ratio (numerator,denominator)
import List (sort)
posRationals = 1 : (posRationals >>= \x -> [1+x, 1/(1+x)]) :: [Rational]
pyth r = (x,y,z) where m = numerator r; n = denominator r; [x,y,z] = sort [2*m*n, m^2 - n^2, m^2 + n^2]
|
view (7 lines, 2425 lines of output) |
try
tell application "Finder" to set pwd to quoted form of POSIX path of (target of front Finder window as alias)
tell application "System Events" to set terminalOn to (exists process "Terminal")
tell application "Terminal"
if terminalOn then
|
view (15 lines) |
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
import sys,re
url = 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?servicetag=%s'
|
view (19 lines) |
#!/usr/bin/env ruby
Dir["*.jpg"].each do |file|
mm,dd,yy,h,m = [0,3,6,9,11].map { |start| file[start,2] }
stamp = "20%s-%s-%s %s:%s" % [yy,mm,dd,h,m]
|
view (8 lines) |
#include <iostream>
#include <csignal>
#include <cstdlib>
#include <unistd.h>
#include <exception>
|
view (39 lines, 1 line of output) |
#include <stdio.h>
const unsigned seed = 0x0C;
const unsigned mask = 0x11;
const unsigned bits = 5;
|
view (21 lines, 1 line of output) |
$sqrt5 = Math.sqrt(5)
$phi = (1+$sqrt5)/2
def fib n
(($phi**n - (1-$phi)**n) / $sqrt5).to_i
end
|
view (6 lines, 10 lines of output) |
require 'socket'
sock = TCPSocket::new("localhost", 9000)
loop do
select([sock,STDIN],nil,nil)[0].each do |x|
|
view (13 lines) |
puts (" "..":").to_a.join + (":".."~").to_a.join
puts ("A".."M").to_a.join + ("M".."Z").to_a.join
puts ("9"..";").to_a.join
|
view (3 lines, 3 lines of output) |
import java.awt.*;
import java.awt.geom.*;
public class ZoomRect {
/** The size of the physical drawing area.
|
view (62 lines) |
module Enumerable
def product
catch :zero do
self.inject 1 do |n,i|
throw :zero,0 if i==0
|
view (12 lines, 1 line of output) |
graycode 1 = [[0],[1]]
graycode (n+1) = map (0:) gn ++ map (1:) (reverse gn) where gn = graycode n
main = mapM_ print (graycode 4)
|
view (4 lines, 16 lines of output) |
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <utility>
|
view (38 lines, 3 lines of output) |
import Control.Parallel
-- http://sequence.complete.org/hwn/20080709
forkbomb :: Integer -> ()
forkbomb n = forkbomb (2*n) `par` forkbomb (2*n+1)
|
view (8 lines, 3 lines of output) |
#include <iostream>
#include <sstream>
#include <boost/static_assert.hpp>
#define ASSERT BOOST_STATIC_ASSERT
|
view (48 lines) |