code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
package dogs
import "fmt" | 1,057Case-sensitivity of identifiers | 0go | 1x5p5 |
def dog = "Benjamin", Dog = "Samba", DOG = "Bernie"
println (dog == DOG ? "There is one dog named ${dog}": "There are three dogs named ${dog}, ${Dog} and ${DOG}.") | 1,057Case-sensitivity of identifiers | 7groovy | jpc7o |
import Text.Printf
main = printf "The three dogs are named%s,%s and%s.\n" dog dOG dOg
where dog = "Benjamin"
dOG = "Samba"
dOg = "Bernie" | 1,057Case-sensitivity of identifiers | 8haskell | tyxf7 |
package main
import (
ed "github.com/Ernyoke/Imger/edgedetection"
"github.com/Ernyoke/Imger/imgio"
"log"
)
func main() {
img, err := imgio.ImreadRGBA("Valve_original_(1).png")
if err != nil {
log.Fatal("Could not read image", err)
}
cny, err := ed.CannyRGBA(img, 15, 45, 5)
if ... | 1,062Canny edge detector | 0go | rktgm |
(ns example
(:gen-class))
(defn prime? [n]
" Prime number test (using Java) "
(.isProbablePrime (biginteger n) 16))
(defn carmichael [p1]
" Triplets of Carmichael primes, with first element prime p1 "
(if (prime? p1)
(into [] (for [h3 (range 2 p1)
:let [g (+ h3 p1)]
d (range 1 g)
... | 1,064Carmichael 3 strong pseudoprimes | 6clojure | siuqr |
def main():
lalpha =
ralpha =
msg =
print(, lalpha)
print(, ralpha)
print(, msg)
print(, do_chao(msg, lalpha, ralpha, 1, 0), )
do_chao(msg, lalpha, ralpha, 1, 1)
def do_chao(msg, lalpha, ralpha, en=1, show=0):
msg = correct_case(msg)
out =
if show:
pri... | 1,055Chaocipher | 3python | 0npsq |
null | 1,056Catalan numbers/Pascal's triangle | 11kotlin | ur3vc |
String dog = "Benjamin";
String Dog = "Samba"; | 1,057Case-sensitivity of identifiers | 9java | 8db06 |
function nextrow (t)
local ret = {}
t[0], t[#t + 1] = 0, 0
for i = 1, #t do ret[i] = t[i - 1] + t[i] end
return ret
end
function catalans (n)
local t, middle = {1}
for i = 1, n do
middle = math.ceil(#t / 2)
io.write(t[middle] - (t[middle + 1] or 0) .. " ")
t = nextrow(ne... | 1,056Catalan numbers/Pascal's triangle | 1lua | 576u6 |
var dog = "Benjamin";
var Dog = "Samba";
var DOG = "Bernie";
document.write("The three dogs are named " + dog + ", " + Dog + ", and " + DOG + "."); | 1,057Case-sensitivity of identifiers | 10javascript | f6wdg |
typedef struct{
int x;
int (*funcPtr)(int);
}functionPair;
int factorial(int num){
if(num==0||num==1)
return 1;
else
return num*factorial(num-1);
}
int main(int argc,char** argv)
{
functionPair response;
if(argc!=2)
retur... | 1,065Call an object method | 5c | itgo2 |
import java.awt.image.BufferedImage;
import java.util.Arrays;
public class CannyEdgeDetector { | 1,062Canny edge detector | 9java | aql1y |
package main
import (
"fmt"
"log"
"strconv"
"strings"
)
func check(err error) {
if err != nil {
log.Fatal(err)
}
} | 1,063Canonicalize CIDR | 0go | f6kd0 |
package main
import (
"fmt"
"log"
"strconv"
) | 1,060Casting out nines | 0go | itkog |
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
import sys
def center_point(p1, p2):
cp = []
for i in range(3):
cp.append((p1[i]+p2[i])/2)
return cp
def sum_point(p1, p2):
sp = []
for i in range(3):
sp.append(p1[i]+p2[i])
r... | 1,059Catmull–Clark subdivision surface | 3python | 7byrm |
txt =
@left = .chars
@right = .chars
def encrypt(char)
coded_char = @left[@right.index(char)]
@left.rotate!(@left.index(coded_char))
part = @left.slice!(1,13).rotate
@left.insert(1, *part)
@right.rotate!(@right.index(char)+1)
part = @right.slice!(2,12).rotate
@right.insert(2, *part)
@left[0]
en... | 1,055Chaocipher | 14ruby | ofa8v |
import Control.Monad (guard)
import Data.Bits ((.|.), (.&.), complement, shiftL, shiftR, zeroBits)
import Data.Maybe (listToMaybe)
import Data.Word (Word32, Word8)
import Text.ParserCombinators.ReadP (ReadP, char, readP_to_S)
import Text.Printf (printf)
import Text.Read.Lex (readDecP)
data CIDR = CIDR Word32 Word8
... | 1,063Canonicalize CIDR | 8haskell | 4jn5s |
co9 n
| n <= 8 = n
| otherwise = co9 $ sum $ filter (/= 9) $ digits 10 n
task2 = filter (\n -> co9 n == co9 (n ^ 2)) [1 .. 100]
task3 k = filter (\n -> n `mod` k == n ^ 2 `mod` k) [1 .. 100] | 1,060Casting out nines | 8haskell | vgn2k |
pub struct Vector3 {pub x: f64, pub y: f64, pub z: f64, pub w: f64}
pub struct Triangle {pub r: [usize; 3], pub(crate) col: [f32; 4], pub(crate) p: [Vector3; 3], n: Vector3, pub t: [Vector2; 3]}
pub struct Mesh{pub v: Vec<Vector3>, pub f: Vec<Triangle>}
impl Triangle{
pub fn new() -> Triangle {return Triangle {r:... | 1,059Catmull–Clark subdivision surface | 15rust | kach5 |
const LEFT_ALPHABET_CT: &str = "HXUCZVAMDSLKPEFJRIGTWOBNYQ";
const RIGHT_ALPHABET_PT: &str = "PTLNBQDEOYSFAVZKGJRIHWXUMC";
const ZENITH: usize = 0;
const NADIR: usize = 12;
const SEQUENCE: &str = "WELLDONEISBETTERTHANWELLSAID";
fn cipher(letter: &char, left: &String, right: &String) -> (usize, char) {
let pos = ri... | 1,055Chaocipher | 15rust | iteod |
fun main(args: Array<String>) {
val dog = "Benjamin"
val Dog = "Samba"
val DOG = "Bernie"
println("The three dogs are named $dog, $Dog and $DOG")
} | 1,057Case-sensitivity of identifiers | 11kotlin | w0rek |
(Long/toHexString 15)
(System/currentTimeMillis)
(.equals 1 2)
(. 1 (equals 2)) | 1,065Call an object method | 6clojure | zmktj |
import java.text.MessageFormat;
import java.text.ParseException;
public class CanonicalizeCIDR {
public static void main(String[] args) {
for (String test : TESTS) {
try {
CIDR cidr = new CIDR(test);
System.out.printf("%-18s ->%s\n", test, cidr.toString());
... | 1,063Canonicalize CIDR | 9java | cuq9h |
dog = "Benjamin"
Dog = "Samba"
DOG = "Bernie"
print( "There are three dogs named "..dog..", "..Dog.." and "..DOG.."." ) | 1,057Case-sensitivity of identifiers | 1lua | x87wz |
int myopenimage(const char *in)
{
static int handle=0;
fprintf(stderr, , in);
return handle++;
}
int main()
{
void *imglib;
int (*extopenimage)(const char *);
int imghandle;
imglib = dlopen(, RTLD_LAZY);
if ( imglib != NULL ) {
*(void **)(&extopenimage) = dlsym(imglib, );
imghan... | 1,066Call a function in a shared library | 5c | vgq2o |
use strict;
use warnings;
use lib '/home/hkdtam/lib';
use Image::EdgeDetect;
my $detector = Image::EdgeDetect->new();
$detector->process('./input.jpg', './output.jpg') or die; | 1,062Canny edge detector | 2perl | zm1tb |
function RGBtoHSV($r, $g, $b) {
$r = $r/255.;
$g = $g/255.;
$b = $b/255.;
$cols = array( => $r, => $g, => $b);
asort($cols, SORT_NUMERIC);
$min = key(array_slice($cols, 1));
$max = key(array_slice($cols, -1));
if($cols[$min] == $cols[$max]) {
$h = 0;
} else {
if($max == ) {
$h = 60. * ( 0 + ( ($... | 1,062Canny edge detector | 12php | bemk9 |
const canonicalize = s => { | 1,063Canonicalize CIDR | 10javascript | 57iur |
import java.util.*;
import java.util.stream.IntStream;
public class CastingOutNines {
public static void main(String[] args) {
System.out.println(castOut(16, 1, 255));
System.out.println(castOut(10, 1, 99));
System.out.println(castOut(17, 1, 288));
}
static List<Integer> castOut(i... | 1,060Casting out nines | 9java | ylq6g |
package main
import "fmt"
type pair [2]int
func cart2(a, b []int) []pair {
p := make([]pair, len(a)*len(b))
i := 0
for _, a := range a {
for _, b := range b {
p[i] = pair{a, b}
i++
}
}
return p
}
func main() {
fmt.Println(cart2([]int{1, 2}, []int{3, 4}... | 1,058Cartesian product of two or more lists | 0go | sijqa |
char lines[HEIGHT][WIDTH];
void init() {
int i, j;
for (i = 0; i < HEIGHT; ++i) {
for (j = 0; j < WIDTH; ++j) lines[i][j] = '*';
}
}
void cantor(int start, int len, int index) {
int i, j, seg = len / 3;
if (seg == 0) return;
for (i = index; i < HEIGHT; ++i) {
for (j = start + s... | 1,067Cantor set | 5c | 9v1m1 |
function main(s, e, bs, pbs) {
bs = bs || 10;
pbs = pbs || 10
document.write('start:', toString(s), ' end:', toString(e),
' base:', bs, ' printBase:', pbs)
document.write('<br>castOutNine: ');
castOutNine()
document.write('<br>kaprekar: ');
kaprekar()
document.write('<br><br>')
... | 1,060Casting out nines | 10javascript | 24ilr |
package main
import "fmt" | 1,064Carmichael 3 strong pseudoprimes | 0go | m2eyi |
class CartesianCategory {
static Iterable multiply(Iterable a, Iterable b) {
assert [a,b].every { it != null }
def (m,n) = [a.size(),b.size()]
(0..<(m*n)).inject([]) { prod, i -> prod << [a[i.intdiv(n)], b[i%n]].flatten() }
}
} | 1,058Cartesian product of two or more lists | 7groovy | aq51p |
import numpy as np
from scipy.ndimage.filters import convolve, gaussian_filter
from scipy.misc import imread, imshow
def CannyEdgeDetector(im, blur = 1, highThreshold = 91, lowThreshold = 31):
im = np.array(im, dtype=float)
im2 = gaussian_filter(im, blur)
im3h = convolve(im2,[[-1,0,1],[-2,0,2],[-1,0,1]])
i... | 1,062Canny edge detector | 3python | 39azc |
use v5.16;
use Socket qw(inet_aton inet_ntoa);
if (!@ARGV) {
chomp(@ARGV = <>);
}
for (@ARGV) {
my ($dotted, $size) = split m
my $binary = sprintf "%032b", unpack('N', inet_aton $dotted);
substr($binary, $size) = 0 x (32 - $size);
$dotted = inet_ntoa(pack 'B32', $binary);
say "$dotte... | 1,063Canonicalize CIDR | 2perl | pwmb0 |
#!/usr/bin/runhaskell
import Data.Numbers.Primes
import Control.Monad (guard)
carmichaels = do
p <- takeWhile (<= 61) primes
h3 <- [2..(p-1)]
let g = h3 + p
d <- [1..(g-1)]
guard $ (g * (p - 1)) `mod` d == 0 && (-1 * p * p) `mod` h3 == d `mod` h3
let q = 1 + (((p - 1) * g) `div` d)
guard $ isPrime q
l... | 1,064Carmichael 3 strong pseudoprimes | 8haskell | ka3h0 |
use constant N => 15;
my @t = (0, 1);
for(my $i = 1; $i <= N; $i++) {
for(my $j = $i; $j > 1; $j--) { $t[$j] += $t[$j-1] }
$t[$i+1] = $t[$i];
for(my $j = $i+1; $j>1; $j--) { $t[$j] += $t[$j-1] }
print $t[$i+1] - $t[$i], " ";
} | 1,056Catalan numbers/Pascal's triangle | 2perl | 8dp0w |
cartProd :: [a] -> [b] -> [(a, b)]
cartProd xs ys =
[ (x, y)
| x <- xs
, y <- ys ] | 1,058Cartesian product of two or more lists | 8haskell | 9vomo |
int add(int num1, int num2) {
return num1 + num2;
} | 1,066Call a function in a shared library | 18dart | ylp65 |
null | 1,060Casting out nines | 11kotlin | f61do |
typedef unsigned long long ull;
ull binomial(ull m, ull n)
{
ull r = 1, d = m - n;
if (d > n) { n = d; d = m - n; }
while (m > n) {
r *= m--;
while (d > 1 && ! (r%d) ) r /= d--;
}
return r;
}
ull catalan1(int n) {
return binomial(2 * n, n) / (1 + n);
}
ull catalan2(int n) {
int i;
ull r = !n;
for (i ... | 1,068Catalan numbers | 5c | m2bys |
import sys
from socket import inet_aton, inet_ntoa
from struct import pack, unpack
args = sys.argv[1:]
if len(args) == 0:
args = sys.stdin.readlines()
for cidr in args:
dotted, size_str = cidr.split('/')
size = int(size_str)
numeric = unpack('!I', inet_aton(dotted))[0]
binary = f'{numeric:
p... | 1,063Canonicalize CIDR | 3python | 1x9pc |
local N = 2
local base = 10
local c1 = 0
local c2 = 0
for k = 1, math.pow(base, N) - 1 do
c1 = c1 + 1
if k % (base - 1) == (k * k) % (base - 1) then
c2 = c2 + 1
io.write(k .. ' ')
end
end
print()
print(string.format("Trying%d numbers instead of%d numbers saves%f%%", c2, c1, 100.0 - 100.0 *... | 1,060Casting out nines | 1lua | tyafn |
>>> n = 15
>>> t = [0] * (n + 2)
>>> t[1] = 1
>>> for i in range(1, n + 1):
for j in range(i, 1, -1): t[j] += t[j - 1]
t[i + 1] = t[i]
for j in range(i + 1, 1, -1): t[j] += t[j - 1]
print(t[i+1] - t[i], end=' ')
1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 9694845
>>> | 1,056Catalan numbers/Pascal's triangle | 3python | of181 |
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static java.util.Optional.of;
import static java.util.stream.Collectors.toList;
import java.util.List;
public class CartesianProduct {
public List<?> product(List<?>... a) {
if (a.length >= 2) {
List<... | 1,058Cartesian product of two or more lists | 9java | tywf9 |
type Foo int | 1,065Call an object method | 0go | ghi4n |
public class Test {
static int mod(int n, int m) {
return ((n % m) + m) % m;
}
static boolean isPrime(int n) {
if (n == 2 || n == 3)
return true;
else if (n < 2 || n % 2 == 0 || n % 3 == 0)
return false;
for (int div = 5, inc = 2; Math.pow(div, 2) <=... | 1,064Carmichael 3 strong pseudoprimes | 9java | 4ji58 |
package main
import (
"fmt"
)
func main() {
n := []int{1, 2, 3, 4, 5}
fmt.Println(reduce(add, n))
fmt.Println(reduce(sub, n))
fmt.Println(reduce(mul, n))
}
func add(a int, b int) int { return a + b }
func sub(a int, b int) int { return a - b }
func mul(a int, b int) int { return a * b }
func reduce(rf func(in... | 1,061Catamorphism | 0go | qo4xz |
(() => { | 1,058Cartesian product of two or more lists | 10javascript | m28yv |
data Obj = Obj { field :: Int, method :: Int -> Int }
mkAdder :: Int -> Obj
mkAdder x = Obj x (+x)
instanse Show Obj where
show o = "Obj " ++ show (field o) | 1,065Call an object method | 8haskell | sivqk |
ClassWithStaticMethod.staticMethodName(argument1, argument2); | 1,065Call an object method | 9java | 1xyp2 |
#include <stdio.h>
int openimage(const char *s)
{
static int handle = 100;
fprintf(stderr, "opening%s\n", s);
return handle++;
} | 1,066Call a function in a shared library | 0go | si2qa |
#!/usr/bin/env stack
import Control.Exception ( try )
import Foreign ( FunPtr, allocaBytes )
import Foreign.C
( CSize(..), CString, withCAStringLen, peekCAStringLen )
import System.Info ( os )
import System.IO.Error ( ioeGetErrorString )
import System.IO.Unsafe ( unsafePerformIO )
import System.Posix.DynamicLinke... | 1,066Call a function in a shared library | 8haskell | 9vamo |
package main
import (
"fmt"
"math"
"math/big"
"strconv"
"strings"
)
func calkinWilf(n int) []*big.Rat {
cw := make([]*big.Rat, n+1)
cw[0] = big.NewRat(1, 1)
one := big.NewRat(1, 1)
two := big.NewRat(2, 1)
for i := 1; i < n; i++ {
t := new(big.Rat).Set(cw[i-1])
f... | 1,069Calkin-Wilf sequence | 0go | of28q |
if ARGV.length == 0 then
ARGV = $stdin.readlines.map(&:chomp)
end
ARGV.each do |cidr|
dotted, size_str = cidr.split('/')
size = size_str.to_i
binary = dotted.split('.').map { |o| % o }.join
binary[size .. -1] = '0' * (32 - size)
canon = binary.chars.each_slice(8).map { |a| a.join.to_i(2)... | 1,063Canonicalize CIDR | 14ruby | eslax |
use std::net::Ipv4Addr;
fn canonical_cidr(cidr: &str) -> Result<String, &str> {
let mut split = cidr.splitn(2, '/');
if let (Some(addr), Some(mask)) = (split.next(), split.next()) {
let addr = addr.parse::<Ipv4Addr>().map(u32::from).map_err(|_| cidr)?;
let mask = mask.parse::<u8>().map_err(|_| ... | 1,063Canonicalize CIDR | 15rust | w02e4 |
fun Int.isPrime(): Boolean {
return when {
this == 2 -> true
this <= 1 || this % 2 == 0 -> false
else -> {
val max = Math.sqrt(toDouble()).toInt()
(3..max step 2)
.filter { this % it == 0 }
.forEach { return false }
true
... | 1,064Carmichael 3 strong pseudoprimes | 11kotlin | l5qcp |
def vector1 = [1,2,3,4,5,6,7]
def vector2 = [7,6,5,4,3,2,1]
def map1 = [a:1, b:2, c:3, d:4]
println vector1.inject { acc, val -> acc + val } | 1,061Catamorphism | 7groovy | 1xlp6 |
(def ! (memoize #(apply * (range 1 (inc %)))))
(defn catalan-numbers-direct []
(map #(/ (! (* 2 %))
(* (! (inc %)) (! %))) (range)))
(def catalan-numbers-recursive
#(->> [1 1]
(iterate (fn [[c n]]
[(* 2 (dec (* 2 n)) (/ (inc n)) c) (inc n)]) ,)
(map first ,)))
user> (take 15 (catalan-numb... | 1,068Catalan numbers | 6clojure | vgw2f |
x.y() | 1,065Call an object method | 10javascript | qo2x8 |
import java.util.Collections;
import java.util.Random;
public class TrySort {
static boolean useC;
static {
try {
System.loadLibrary("TrySort");
useC = true;
} catch(UnsatisfiedLinkError e) {
useC = false;
}
}
static native void sortInC(int[] ary);
static class IntList extends j... | 1,066Call a function in a shared library | 9java | tyjf9 |
import Control.Monad (forM_)
import Data.Bool (bool)
import Data.List.NonEmpty (NonEmpty, fromList, toList, unfoldr)
import Text.Printf (printf)
calkinWilfs :: [Rational]
calkinWilfs = iterate (recip . succ . ((-) =<< (2 *) . fromIntegral . floor)) 1
calkinWilfIdx :: Rational -> Integer
calkinWilfIdx = rld . cfo
... | 1,069Calkin-Wilf sequence | 8haskell | 24all |
local function isprime(n)
if n < 2 then return false end
if n % 2 == 0 then return n==2 end
if n % 3 == 0 then return n==3 end
local f, limit = 5, math.sqrt(n)
while (f <= limit) do
if n % f == 0 then return false end; f=f+2
if n % f == 0 then return false end; f=f+4
end
return true
end
local fun... | 1,064Carmichael 3 strong pseudoprimes | 1lua | 24sl3 |
main :: IO ()
main =
putStrLn . unlines $
[ show . foldr (+) 0
, show . foldr (*) 1
, foldr ((++) . show) ""
] <*>
[[1 .. 10]] | 1,061Catamorphism | 8haskell | m2qyf |
class MyClass {
fun instanceMethod(s: String) = println(s)
companion object {
fun staticMethod(s: String) = println(s)
}
}
fun main(args: Array<String>) {
val mc = MyClass()
mc.instanceMethod("Hello instance world!")
MyClass.staticMethod("Hello static world!")
} | 1,065Call an object method | 11kotlin | jpf7r |
int main(int argc,char** argv) {
int arg1 = atoi(argv[1]), arg2 = atoi(argv[2]), sum, diff, product, quotient, remainder ;
__asm__ ( : (sum) : (arg1) , (arg2) );
__asm__ ( : (diff) : (arg1) , (arg2) );
__asm__ ( : (product) : (arg1) , (arg2) );
__asm__ (
... | 1,070Call a foreign-language function | 5c | 57wuk |
sub co9 {
my $n = shift;
return $n if $n < 10;
my $sum = 0; $sum += $_ for split(//,$n);
co9($sum);
}
sub showadd {
my($n,$m) = @_;
print "( $n [",co9($n),"] + $m [",co9($m),"] ) [",co9(co9($n)+co9($m)),"]",
" = ", $n+$m," [",co9($n+$m),"]\n";
}
sub co9filter {
my $base = shift;
die unl... | 1,060Casting out nines | 2perl | h1mjl |
def catalan(num)
t = [0, 1]
(1..num).map do |i|
i.downto(1){|j| t[j] += t[j-1]}
t[i+1] = t[i]
(i+1).downto(1) {|j| t[j] += t[j-1]}
t[i+1] - t[i]
end
end
p catalan(15) | 1,056Catalan numbers/Pascal's triangle | 14ruby | nzeit |
null | 1,058Cartesian product of two or more lists | 11kotlin | ofb8z |
#include <stdio.h>
int openimage(const char *s)
{
static int handle = 100;
fprintf(stderr, "opening%s\n", s);
return handle++;
} | 1,066Call a function in a shared library | 11kotlin | of58z |
(JNIDemo/callStrdup "Hello World!") | 1,070Call a foreign-language function | 6clojure | jp87m |
import java.util.stream.Stream;
public class ReduceTask {
public static void main(String[] args) {
System.out.println(Stream.of(1, 2, 3, 4, 5).mapToInt(i -> i).sum());
System.out.println(Stream.of(1, 2, 3, 4, 5).reduce(1, (a, b) -> a * b));
}
} | 1,061Catamorphism | 9java | f6pdv |
fn main()
{let n=15usize;
let mut t= [0; 17];
t[1]=1;
let mut j:usize;
for i in 1..n+1
{
j=i;
loop{
if j==1{
break;
}
t[j]=t[j] + t[j-1];
j=j-1;
}
t[i+1]= t[i];
j=i+1;
loop{
if j==1{
break;
}
t[j]=t[j] + t[j-1];
j=j-1;
}
print!("{} ", t[i+1]-t[i]);
}
} | 1,056Catalan numbers/Pascal's triangle | 15rust | d3wny |
def catalan(n: Int): Int =
if (n <= 1) 1
else (0 until n).map(i => catalan(i) * catalan(n - i - 1)).sum
(1 to 15).map(catalan(_)) | 1,056Catalan numbers/Pascal's triangle | 16scala | zmstr |
$dog='Benjamin';
$Dog='Samba';
$DOG='Bernie';
print "The three dogs are named $dog, $Dog, and $DOG \n" | 1,057Case-sensitivity of identifiers | 2perl | l5dc5 |
local object = { name = "foo", func = function (self) print(self.name) end }
object:func() | 1,065Call an object method | 1lua | h1tj8 |
alien = require("alien")
msgbox = alien.User32.MessageBoxA
msgbox:types({ ret='long', abi='stdcall', 'long', 'string', 'string', 'long' })
retval = msgbox(0, 'Please press Yes, No or Cancel', 'The Title', 3)
print(retval) | 1,066Call a function in a shared library | 1lua | it4ot |
package main
import "fmt"
const (
width = 81
height = 5
)
var lines [height][width]byte
func init() {
for i := 0; i < height; i++ {
for j := 0; j < width; j++ {
lines[i][j] = '*'
}
}
}
func cantor(start, len, index int) {
seg := len / 3
if seg == 0 {
retu... | 1,067Cantor set | 0go | esya6 |
use ntheory qw/forprimes is_prime vecprod/;
forprimes { my $p = $_;
for my $h3 (2 .. $p-1) {
my $ph3 = $p + $h3;
for my $d (1 .. $ph3-1) {
next if ((-$p*$p) % $h3) != ($d % $h3);
next if (($p-1)*$ph3) % $d;
my $q = 1 + ($p-1)*$ph3 / $d;
next unl... | 1,064Carmichael 3 strong pseudoprimes | 2perl | qovx6 |
var nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function add(a, b) {
return a + b;
}
var summation = nums.reduce(add);
function mul(a, b) {
return a * b;
}
var product = nums.reduce(mul, 1);
var concatenation = nums.reduce(add, "");
console.log(summation, product, concatenation); | 1,061Catamorphism | 10javascript | ylx6r |
local pk,upk = table.pack, table.unpack
local getn = function(t)return #t end
local const = function(k)return function(e) return k end end
local function attachIdx(f) | 1,058Cartesian product of two or more lists | 1lua | itpot |
class App {
private static final int WIDTH = 81
private static final int HEIGHT = 5
private static char[][] lines
static {
lines = new char[HEIGHT][WIDTH]
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < WIDTH; j++) {
lines[i][j] = '*'
}
... | 1,067Cantor set | 7groovy | kafh7 |
use strict;
use warnings;
use feature qw(say state);
use ntheory 'fromdigits';
use List::Lazy 'lazy_list';
use Math::AnyNum ':overload';
my $calkin_wilf = lazy_list { state @cw = 1; push @cw, 1 / ( (2 * int $cw[0]) + 1 - $cw[0] ); shift @cw };
sub r2cf {
my($num, $den) = @_;
my($n, @cf);
my $f = sub { r... | 1,069Calkin-Wilf sequence | 2perl | jpo7f |
def CastOut(Base=10, Start=1, End=999999):
ran = [y for y in range(Base-1) if y%(Base-1) == (y*y)%(Base-1)]
x,y = divmod(Start, Base-1)
while True:
for n in ran:
k = (Base-1)*x + n
if k < Start:
continue
if k > End:
return
yield k
x += 1
for V in CastOut(Base=16,St... | 1,060Casting out nines | 3python | ka9hf |
cantor :: [(Bool, Int)] -> [(Bool, Int)]
cantor = concatMap go
where
go (bln, n)
| bln && 1 < n =
let m = quot n 3
in [(True, m), (False, m), (True, m)]
| otherwise = [(bln, n)]
main :: IO ()
main = putStrLn $ cantorLines 5
cantorLines :: Int -> String
cantorLines n =
unline... | 1,067Cantor set | 8haskell | 39hzj |
fun main(args: Array<String>) {
val a = intArrayOf(1, 2, 3, 4, 5)
println("Array : ${a.joinToString(", ")}")
println("Sum : ${a.reduce { x, y -> x + y }}")
println("Difference : ${a.reduce { x, y -> x - y }}")
println("Product : ${a.reduce { x, y -> x * y }}")
println("Minimum ... | 1,061Catamorphism | 11kotlin | 8d70q |
>>> dog = 'Benjamin'; Dog = 'Samba'; DOG = 'Bernie'
>>> print ('The three dogs are named ',dog,', ',Dog,', and ',DOG)
The three dogs are named Benjamin , Samba , and Bernie
>>> | 1,057Case-sensitivity of identifiers | 3python | 24flz |
dog <- 'Benjamin'
Dog <- 'Samba'
DOG <- 'Bernie'
cat('The three dogs are named ')
cat(dog)
cat(', ')
cat(Dog)
cat(' and ')
cat(DOG)
cat('.\n') | 1,057Case-sensitivity of identifiers | 13r | m2oy4 |
const char STX = '\002', ETX = '\003';
int compareStrings(const void *a, const void *b) {
char *aa = *(char **)a;
char *bb = *(char **)b;
return strcmp(aa, bb);
}
int bwt(const char *s, char r[]) {
int i, len = strlen(s) + 2;
char *ss, *str;
char **table;
if (strchr(s, STX) || strchr(s, ET... | 1,071Burrows–Wheeler transform | 5c | qo6xc |
public class App {
private static final int WIDTH = 81;
private static final int HEIGHT = 5;
private static char[][] lines;
static {
lines = new char[HEIGHT][WIDTH];
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j < WIDTH; j++) {
lines[i][j] = '*';
... | 1,067Cantor set | 9java | it5os |
from fractions import Fraction
from math import floor
from itertools import islice, groupby
def cw():
a = Fraction(1)
while True:
yield a
a = 1 / (2 * floor(a) + 1 - a)
def r2cf(rational):
num, den = rational.numerator, rational.denominator
while den:
num, (digit, den) = den, ... | 1,069Calkin-Wilf sequence | 3python | h1ijw |
class Isprime():
'''
Extensible sieve of Eratosthenes
>>> isprime.check(11)
True
>>> isprime.multiples
{2, 4, 6, 8, 9, 10}
>>> isprime.primes
[2, 3, 5, 7, 11]
>>> isprime(13)
True
>>> isprime.multiples
{2, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 18, 20, 21, 22}
>>> is... | 1,064Carmichael 3 strong pseudoprimes | 3python | siuq9 |
MyClass->classMethod($someParameter);
my $foo = 'MyClass';
$foo->classMethod($someParameter);
$myInstance->method($someParameter);
$myInstance->anotherMethod;
MyClass::classMethod('MyClass', $someParameter);
MyClass::method($myInstance, $someParameter); | 1,065Call an object method | 2perl | tyhfg |
use Inline
C => "DATA",
ENABLE => "AUTOWRAP",
LIBS => "-lm";
print 4*atan(1) . "\n";
__DATA__
__C__
double atan(double x); | 1,066Call a function in a shared library | 2perl | gho4e |
int main(int argc, char* argv[])
{
double e;
puts(
);
e = exp(1);
printf(, e);
int n = 8192;
e = 1.0 + 1.0 / n;
for (int i = 0; i < 13; i++)
e *= e;
printf(, e);
const int N = 1000;
double a[1000];
a[0] = 1.0;
for (i... | 1,072Calculating the value of e | 5c | 394za |
(() => {
"use strict"; | 1,067Cantor set | 10javascript | zmjt2 |
N = 2
base = 10
c1 = 0
c2 = 0
for k in 1 .. (base ** N) - 1
c1 = c1 + 1
if k % (base - 1) == (k * k) % (base - 1) then
c2 = c2 + 1
print % [k]
end
end
puts
print % [c2, c1, 100.0 - 100.0 * c2 / c1] | 1,060Casting out nines | 14ruby | pwlbh |
table.unpack = table.unpack or unpack | 1,061Catamorphism | 1lua | ofj8h |
module FiveDogs
dog =
dOg =
doG =
Dog =
DOG =
names = [dog, dOg, doG, Dog, DOG]
names.uniq!
puts % [names.length, names.join()]
puts
puts % local_variables.join()
puts % constants.join()
end | 1,057Case-sensitivity of identifiers | 14ruby | urzvz |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.