code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(" x math.Gamma Lanczos7")
for _, x := range []float64{-.5, .1, .5, 1, 1.5, 2, 3, 10, 140, 170} {
fmt.Printf("%5.1f%24.16g%24.16g\n", x, math.Gamma(x), lanczos7(x))
}
}
func lanczos7(z float64) ... | 802Gamma function | 0go | 7sjr2 |
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
public class FractalTree extends JFrame {
public FractalTree() {
super("Fractal Tree");
setBounds(100, 100, 800, 600);
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
private void d... | 804Fractal tree | 9java | 7qgrj |
(() => {
"use strict"; | 803Fusc sequence | 10javascript | kokhq |
a = [ 1.00000000000000000000, 0.57721566490153286061, -0.65587807152025388108,
-0.04200263503409523553, 0.16653861138229148950, -0.04219773455554433675,
-0.00962197152787697356, 0.00721894324666309954, -0.00116516759185906511,
-0.00021524167411495097, 0.00012805028238811619, -0.00002013485478078824,
... | 802Gamma function | 7groovy | ua5v9 |
$rows_of_pins = 12
$width = $rows_of_pins * 10 + ($rows_of_pins+1)*14
Shoes.app(
:width => $width + 14,
:title =>
) do
@bins = Array.new($rows_of_pins+1, 0)
@x_coords = Array.new($rows_of_pins) {Array.new}
@y_coords = Array.new($rows_of_pins)
stack(:width => $width) do
stroke gray
fill gray
... | 798Galton box animation | 14ruby | rqbgs |
def general_fizzbuzz(text)
num, *nword = text.split
num = num.to_i
dict = nword.each_slice(2).map{|n,word| [n.to_i,word]}
(1..num).each do |i|
str = dict.map{|n,word| word if i%n==0}.join
puts str.empty?? i: str
end
end
text = <<EOS
20
3 Fizz
5 Buzz
7 Baxx
EOS
general_fizzbuzz(text) | 791General FizzBuzz | 14ruby | 7ssri |
<html>
<body>
<canvas id="canvas" width="600" height="500"></canvas>
<script type="text/javascript">
var elem = document.getElementById('canvas');
var context = elem.getContext('2d');
context.fillStyle = '#C0C0C0';
context.lineWidth = 1;
var deg_to_rad = Math.PI / 180.0;
var depth = 9;
function drawLine(x1, y1, x2,... | 804Fractal tree | 10javascript | pikb7 |
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FractionReduction {
public static void main(String[] args) {
for ( int size = 2 ; size <= 5 ; size++ ) {
reduce(size);
}
}
private stat... | 807Fraction reduction | 9java | z5itq |
cof :: [Double]
cof =
[ 76.18009172947146
, -86.50532032941677
, 24.01409824083091
, -1.231739572450155
, 0.001208650973866179
, -0.000005395239384953
]
ser :: Double
ser = 1.000000000190015
gammaln :: Double -> Double
gammaln xx =
let tmp_ = (xx + 5.5) - (xx + 0.5) * log (xx + 5.5)
ser_ = ser +... | 802Gamma function | 8haskell | 89o0z |
use std::io;
use std::io::BufRead;
fn parse_entry(l: &str) -> (i32, String) {
let params: Vec<&str> = l.split(' ').collect();
let divisor = params[0].parse::<i32>().unwrap();
let word = params[1].to_string();
(divisor, word)
}
fn main() {
let stdin = io::stdin();
let mut lines = stdin.lock().... | 791General FizzBuzz | 15rust | j0072 |
$ scala GeneralFizzBuzz.scala
20
3 Fizz
5 Buzz
7 Baxx
^D
1
2
Fizz
4
Buzz
Fizz
Baxx
8
Fizz
Buzz
11
Fizz
13
Baxx
FizzBuzz
16
17
Fizz
19
Buzz | 791General FizzBuzz | 16scala | biik6 |
function getAlphabet ()
local letters = {}
for ascii = 97, 122 do table.insert(letters, string.char(ascii)) end
return letters
end
local alpha = getAlphabet()
print(alpha[25] .. alpha[1] .. alpha[25]) | 796Generate lower case ASCII alphabet | 1lua | af81v |
<?php
echo ;
?> | 755Hello world/Text | 12php | i22ov |
def powers(m)
return enum_for(__method__, m) unless block_given?
0.step{|n| yield n**m}
end
def squares_without_cubes
return enum_for(__method__) unless block_given?
cubes = powers(3)
c = cubes.next
powers(2) do |s|
c = cubes.next while c < s
yield s unless c == s
end
end
p squares_without_cube... | 788Generator/Exponential | 14ruby | 3gjz7 |
null | 803Fusc sequence | 11kotlin | 2p2li |
use Math::Matrix;
my $a = Math::Matrix->new([0,1,0],
[0,0,1],
[2,0,1]);
my $b = Math::Matrix->new([1],
[2],
[4]);
my $x = $a->concat($b)->solve;
print $x; | 794Gaussian elimination | 2perl | uabvr |
use std::cmp::Ordering;
use std::iter::Peekable;
fn powers(m: u32) -> impl Iterator<Item = u64> {
(0u64..).map(move |x| x.pow(m))
}
fn noncubic_squares() -> impl Iterator<Item = u64> {
NoncubicSquares {
squares: powers(2).peekable(),
cubes: powers(3).peekable(),
}
}
struct NoncubicSquares... | 788Generator/Exponential | 15rust | 6rh3l |
null | 804Fractal tree | 11kotlin | u12vc |
fun indexOf(n: Int, s: IntArray): Int {
for (i_j in s.withIndex()) {
if (n == i_j.value) {
return i_j.index
}
}
return -1
}
fun getDigits(n: Int, le: Int, digits: IntArray): Boolean {
var mn = n
var mle = le
while (mn > 0) {
val r = mn % 10
if (r == 0... | 807Fraction reduction | 11kotlin | icqo4 |
function fusc(n)
n = math.floor(n)
if n == 0 or n == 1 then
return n
elseif n % 2 == 0 then
return fusc(n / 2)
else
return fusc((n - 1) / 2) + fusc((n + 1) / 2)
end
end
function numLen(n)
local sum = 1
while n > 9 do
n = math.floor(n / 10)
sum = sum +... | 803Fusc sequence | 1lua | v1v2x |
import Foundation
print("Input max number: ", terminator: "")
guard let maxN = Int(readLine()?? "0"), maxN > 0 else {
fatalError("Please input a number greater than 0")
}
func getFactor() -> (Int, String) {
print("Enter a factor and phrase: ", terminator: "")
guard let factor1Input = readLine() else {
fat... | 791General FizzBuzz | 17swift | rqqgg |
object Generators {
def main(args: Array[String]): Unit = {
def squares(n:Int=0):Stream[Int]=(n*n) #:: squares(n+1)
def cubes(n:Int=0):Stream[Int]=(n*n*n) #:: cubes(n+1)
def filtered(s:Stream[Int], c:Stream[Int]):Stream[Int]={
if(s.head>c.head) filtered(s, c.tail)
else if(s.head<... | 788Generator/Exponential | 16scala | 9hpm5 |
function indexOf(haystack, needle)
for idx,straw in pairs(haystack) do
if straw == needle then
return idx
end
end
return -1
end
function getDigits(n, le, digits)
while n > 0 do
local r = n % 10
if r == 0 or indexOf(digits, r) > 0 then
return fals... | 807Fraction reduction | 1lua | nlsi8 |
public class GammaFunction {
public double st_gamma(double x){
return Math.sqrt(2*Math.PI/x)*Math.pow((x/Math.E), x);
}
public double la_gamma(double x){
double[] p = {0.99999999999980993, 676.5203681218851, -1259.1392167224028,
771.32342877765313, -176.61502916214059, 12.507343278686905,
... | 802Gamma function | 9java | etwa5 |
from itertools import islice, count
for start, n in [(100, 30), (1_000_000, 15), (1_000_000_000, 10)]:
print(f)
print(list(islice(( x for x in count(start)
if (x% (int(str(x)[0]) * 10 + (x% 10)) == 0) )
, n))) | 793Gapful numbers | 3python | 89y0o |
function swap_rows(&$a, &$b, $r1, $r2)
{
if ($r1 == $r2) return;
$tmp = $a[$r1];
$a[$r1] = $a[$r2];
$a[$r2] = $tmp;
$tmp = $b[$r1];
$b[$r1] = $b[$r2];
$b[$r2] = $tmp;
}
function gauss_eliminate($A, $b, $N)
{
for ($col = 0; $col < $N; $col++)
{
$j = $col;
$max = $A[... | 794Gaussian elimination | 12php | 8960m |
function gamma(x) {
var p = [0.99999999999980993, 676.5203681218851, -1259.1392167224028,
771.32342877765313, -176.61502916214059, 12.507343278686905,
-0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7
];
var g = 7;
if (x < 0.5) {
return Math.PI / (Math.sin(Math.... | 802Gamma function | 10javascript | 0m8sz |
use strict;
use warnings;
use feature 'say';
sub comma { reverse ((reverse shift) =~ s/(.{3})/$1,/gr) =~ s/^,//r }
sub stern_diatomic {
my ($p,$q,$i) = (0,1,shift);
while ($i) {
if ($i & 1) { $p += $q; } else { $q += $p; }
$i >>= 1;
}
$p;
}
say "First 61 terms of the Fusc sequence:\n" . join ' ', map... | 803Fusc sequence | 2perl | sysq3 |
null | 806Function composition | 0go | s6eqa |
g, angle = love.graphics, 26 * math.pi / 180
wid, hei = g.getWidth(), g.getHeight()
function rotate( x, y, a )
local s, c = math.sin( a ), math.cos( a )
local a, b = x * c - y * s, x * s + y * c
return a, b
end
function branches( a, b, len, ang, dir )
len = len * .76
if len < 5 then return end
g.setColor( l... | 804Fractal tree | 1lua | 5avu6 |
package main
import (
"fmt"
"log"
"math/big"
"os"
"strconv"
"strings"
)
func compile(src string) ([]big.Rat, bool) {
s := strings.Fields(src)
r := make([]big.Rat, len(s))
for i, s1 := range s {
if _, ok := r[i].SetString(s1); !ok {
return nil, false
}
... | 805Fractran | 0go | 1nkp5 |
class Integer
def gapful?
a = digits
self % (a.last*10 + a.first) == 0
end
end
specs = {100 => 30, 1_000_000 => 15, 1_000_000_000 => 10, 7123 => 25}
specs.each do |start, num|
puts
p (start..).lazy.select(&:gapful?).take(num).to_a
end | 793Gapful numbers | 14ruby | il9oh |
import copy
from fractions import Fraction
def gauss(a, b):
a = copy.deepcopy(a)
b = copy.deepcopy(b)
n = len(a)
p = len(b[0])
det = 1
for i in range(n - 1):
k = i
for j in range(i + 1, n):
if abs(a[j][i]) > abs(a[k][i]):
k = j
if k != i:
... | 794Gaussian elimination | 3python | 5epux |
final times2 = { it * 2 }
final plus1 = { it + 1 }
final plus1_then_times2 = times2 << plus1
final times2_then_plus1 = times2 >> plus1
assert plus1_then_times2(3) == 8
assert times2_then_plus1(3) == 7 | 806Function composition | 7groovy | adk1p |
Prelude> let sin_asin = sin . asin
Prelude> sin_asin 0.5
0.49999999999999994 | 806Function composition | 8haskell | 9j3mo |
import Data.List (find)
import Data.Ratio (Ratio, (%), denominator)
fractran :: (Integral a) => [Ratio a] -> a -> [a]
fractran fracts n = n:
case find (\f -> n `mod` denominator f == 0) fracts of
Nothing -> []
Just f -> fractran fracts $ truncate (fromIntegral n * f) | 805Fractran | 8haskell | tunf7 |
gauss <- function(a, b) {
n <- nrow(a)
det <- 1
for (i in seq_len(n - 1)) {
j <- which.max(a[i:n, i]) + i - 1
if (j!= i) {
a[c(i, j), i:n] <- a[c(j, i), i:n]
b[c(i, j), ] <- b[c(j, i), ]
det <- -det
}
k <- seq(i + 1, n)
for (j in k) {
s <- a[[j, i]] / a[[i, i]]
... | 794Gaussian elimination | 13r | lbjce |
func powGen(m: Int) -> GeneratorOf<Int> {
let power = Double(m)
var cur: Double = 0
return GeneratorOf { Int(pow(cur++, power)) }
}
var squares = powGen(2)
var cubes = powGen(3)
var nCube = cubes.next()
var filteredSqs = GeneratorOf<Int> {
for var nSq = squares.next();; nCube = cubes.next() {
if nCube > ... | 788Generator/Exponential | 17swift | z47tu |
use strict;
use warnings;
use feature 'say';
use List::Util qw<sum uniq uniqnum head tail>;
for my $exp (map { $_ - 1 } <2 3 4>) {
my %reduced;
my $start = sum map { 10 ** $_ * ($exp - $_ + 1) } 0..$exp;
my $end = 10**($exp+1) - -1 + sum map { 10 ** $_ * ($exp - $_) } 0..$exp-1;
for my $den ($start ... | 807Fraction reduction | 2perl | rxvgd |
null | 802Gamma function | 11kotlin | kobh3 |
public class Compose { | 806Function composition | 9java | tuif9 |
from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... | 803Fusc sequence | 3python | 0m0sq |
WITH
FUNCTION gapful_numbers(p_start IN INTEGER, p_count IN INTEGER) RETURN varchar2 IS
v_start INTEGER:= p_start;
v_count INTEGER:= 0;
v_res varchar2(32767);
BEGIN
v_res:= 'First '||p_count||' gapful numbers starting from '||p_start||': ';
-- main cycle
while TRUE loop
IF MOD... | 793Gapful numbers | 19sql | 6r43m |
function compose(f, g) {
return function(x) {
return f(g(x));
};
} | 806Function composition | 10javascript | m7zyv |
use GD::Simple;
my ($width, $height) = (1000,1000);
my $scale = 6/10;
my $length = 400;
my $img = GD::Simple->new($width,$height);
$img->fgcolor('black');
$img->penSize(1,1);
tree($width/2, $height, $length, 270);
print $img->png;
sub tree
{
my ($x, $y, $len, $angle) = @_;
return if $len < 1;
... | 804Fractal tree | 2perl | 8ms0w |
def indexOf(haystack, needle):
idx = 0
for straw in haystack:
if straw == needle:
return idx
else:
idx += 1
return -1
def getDigits(n, le, digits):
while n > 0:
r = n% 10
if r == 0 or indexOf(digits, r) >= 0:
return False
le -=... | 807Fraction reduction | 3python | 7qurm |
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Fractran{
public static void main(String []args){
new Fractran("17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1", 2);
}
final int limit = 15;
Vector<Integer> nu... | 805Fractran | 9java | 8mq06 |
firstNFuscNumbers <- function(n)
{
stopifnot(n > 0)
if(n == 1) return(0) else fusc <- c(0, 1)
if(n > 2)
{
for(i in seq(from = 3, to = n, by = 1))
{
fusc[i] <- if(i %% 2) fusc[(i + 1) / 2] else fusc[i / 2] + fusc[(i + 2) / 2]
}
}
fusc
}
first61 <- firstNFuscNumbers(61)
cat("The first 61 Fus... | 803Fusc sequence | 13r | wzwe5 |
gamma, coeff, quad, qui, set = 0.577215664901, -0.65587807152056, -0.042002635033944, 0.16653861138228, -0.042197734555571
function recigamma(z)
return z + gamma * z^2 + coeff * z^3 + quad * z^4 + qui * z^5 + set * z^6
end
function gammafunc(z)
if z == 1 then return 1
elseif math.abs(z) <= 0.5 then return 1 / re... | 802Gamma function | 1lua | bipka |
func isGapful(n: Int) -> Bool {
guard n > 100 else {
return true
}
let asString = String(n)
let div = Int("\(asString.first!)\(asString.last!)")!
return n% div == 0
}
let first30 = (100...).lazy.filter(isGapful).prefix(30)
let mil = (1_000_000...).lazy.filter(isGapful).prefix(15)
let bil = (1_000_000_0... | 793Gapful numbers | 17swift | ocm8k |
print 'a'..'z' | 796Generate lower case ASCII alphabet | 2perl | mj5yz |
null | 805Fractran | 10javascript | fvidg |
require 'bigdecimal/ludcmp'
include LUSolve
BigDecimal::limit(30)
a = [1.00, 0.00, 0.00, 0.00, 0.00, 0.00,
1.00, 0.63, 0.39, 0.25, 0.16, 0.10,
1.00, 1.26, 1.58, 1.98, 2.49, 3.13,
1.00, 1.88, 3.55, 6.70, 12.62, 23.80,
1.00, 2.51, 6.32, 15.88, 39.90, 100.28,
1.00, 3.14, 9.87, 31.01, 97.41, 306.... | 794Gaussian elimination | 14ruby | gxa4q |
<?php
$lower = range('a', 'z');
var_dump($lower);
?> | 796Generate lower case ASCII alphabet | 12php | etoa9 |
<?php
header();
$width = 512;
$height = 512;
$img = imagecreatetruecolor($width,$height);
$bg = imagecolorallocate($img,255,255,255);
imagefilledrectangle($img, 0, 0, $width, $width, $bg);
$depth = 8;
function drawTree($x1, $y1, $angle, $depth){
global $img;
if ($depth != 0){
$x2 = $x1 + (int)(cos(d... | 804Fractal tree | 12php | 4eu5n |
null | 794Gaussian elimination | 15rust | rqeg5 |
null | 806Function composition | 11kotlin | o9q8z |
null | 805Fractran | 11kotlin | wt1ek |
fusc = Enumerator.new do |y|
y << 0
y << 1
arr = [0,1]
2.step do |n|
res = n.even?? arr[n/2]: arr[(n-1)/2] + arr[(n+1)/2]
y << res
arr << res
end
end
fusc_max_digits = Enumerator.new do |y|
cur_max, cur_exp = 0, 0
0.step do |i|
f = fusc.next
if f >= cur_max
cur_exp += ... | 803Fusc sequence | 14ruby | oco8v |
def indexOf(haystack, needle)
idx = 0
for straw in haystack
if straw == needle then
return idx
else
idx = idx + 1
end
end
return -1
end
def getDigits(n, le, digits)
while n > 0
r = n % 10
if r == 0 or indexOf(digits, r) >= 0 then
... | 807Fraction reduction | 14ruby | h04jx |
fn fusc_sequence() -> impl std::iter::Iterator<Item = u32> {
let mut sequence = vec![0, 1];
let mut n = 0;
std::iter::from_fn(move || {
if n > 1 {
sequence.push(match n% 2 {
0 => sequence[n / 2],
_ => sequence[(n - 1) / 2] + sequence[(n + 1) / 2],
... | 803Fusc sequence | 15rust | iliod |
function compose(f, g) return function(...) return f(g(...)) end end | 806Function composition | 1lua | icsot |
struct FuscSeq: Sequence, IteratorProtocol {
private var arr = [0, 1]
private var i = 0
mutating func next() -> Int? {
defer {
i += 1
}
guard i > 1 else {
return arr[i]
}
switch i & 1 {
case 0:
arr.append(arr[i / 2])
case 1:
arr.append(arr[(i - 1) / 2] + arr[... | 803Fusc sequence | 17swift | 8980v |
func gaussEliminate(_ sys: [[Double]]) -> [Double]? {
var system = sys
let size = system.count
for i in 0..<size-1 where system[i][i]!= 0 {
for j in i..<size-1 {
let factor = system[j + 1][i] / system[i][i]
for k in i..<size+1 {
system[j + 1][k] -= factor * system[i][k]
}
}
... | 794Gaussian elimination | 17swift | 4w15g |
from string import ascii_lowercase
lower = [chr(i) for i in range(ord('a'), ord('z') + 1)] | 796Generate lower case ASCII alphabet | 3python | 9h4mf |
letters
sapply(97:122, intToUtf8) | 796Generate lower case ASCII alphabet | 13r | 3g2zt |
import pygame, math
pygame.init()
window = pygame.display.set_mode((600, 600))
pygame.display.set_caption()
screen = pygame.display.get_surface()
def drawTree(x1, y1, angle, depth):
fork_angle = 20
base_len = 10.0
if depth > 0:
x2 = x1 + int(math.cos(math.radians(angle)) * depth * base_len)
... | 804Fractal tree | 3python | o9081 |
use strict;
use warnings;
use Math::BigRat;
my ($n, @P) = map Math::BigRat->new($_), qw{
2 17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1
};
$|=1;
MAIN: for( 1 .. 5000 ) {
print " " if $_ > 1;
my ($pow, $rest) = (0, $n->copy);
until( $rest->is_odd ) {
++$pow;
$rest->bdiv(2);
... | 805Fractran | 2perl | lkmc5 |
double multiply(double a, double b)
{
return a * b;
} | 808Function definition | 5c | gwl45 |
plotftree <- function(x, y, a, d, c) {
x2=y2=0; d2r=pi/180.0; a1 <- a*d2r; d1=0;
if(d<=0) {return()}
if(d>0)
{ d1=d*10.0;
x2=x+cos(a1)*d1;
y2=y+sin(a1)*d1;
segments(x*c, y*c, x2*c, y2*c, col='darkgreen');
plotftree(x2,y2,a-20,d-1,c);
plotftree(x2,y2,a+20,d-1,c);
}
}
pFractalTree <- funct... | 804Fractal tree | 13r | q3wxs |
use strict;
use warnings;
use constant pi => 4*atan2(1, 1);
use constant e => exp(1);
my $have_MPFR = eval { require Math::MPFR; Math::MPFR->import(); 1; };
sub Gamma {
my $z = shift;
my $method = shift // 'lanczos';
if ($method eq 'lanczos') {
use constant g => 9;
$z < .5 ? pi / sin(... | 802Gamma function | 2perl | 3g6zs |
p ('a' .. 'z').to_a
p [*'a' .. 'z'] | 796Generate lower case ASCII alphabet | 14ruby | lbrcl |
fn main() { | 796Generate lower case ASCII alphabet | 15rust | 2p7lt |
from fractions import Fraction
def fractran(n, fstring='17 / 91, 78 / 85, 19 / 51, 23 / 38, 29 / 33,'
'77 / 29, 95 / 23, 77 / 19, 1 / 17, 11 / 13,'
'13 / 11, 15 / 14, 15 / 2, 55 / 1'):
flist = [Fraction(f) for f in fstring.replace(' ', '').split(',')]
n = Fracti... | 805Fractran | 3python | 2b9lz |
object Abc extends App {
val lowAlpha = 'a' to 'z' | 796Generate lower case ASCII alphabet | 16scala | 5ekut |
Shoes.app(:title => , :width => 600, :height => 600) do
background
stroke
@deg_to_rad = Math::PI / 180.0
def drawTree(x1, y1, angle, depth)
if depth!= 0
x2 = x1 + (Math.cos(angle * @deg_to_rad) * depth * 10.0).to_i
y2 = y1 + (Math.sin(angle * @deg_to_rad) * depth * 10.0).to_i
line x1, ... | 804Fractal tree | 14ruby | nloit |
null | 804Fractal tree | 15rust | d2iny |
import swing._
import java.awt.{RenderingHints, BasicStroke, Color}
object FractalTree extends SimpleSwingApplication {
val DEPTH = 9
def top = new MainFrame {
contents = new Panel {
preferredSize = new Dimension(600, 500)
override def paintComponent(g: Graphics2D) {
draw(300, 460, -90, D... | 804Fractal tree | 16scala | z5ftr |
(defn multiply [x y]
(* x y))
(multiply 4 5) | 808Function definition | 6clojure | k84hs |
_a = ( 1.00000000000000000000, 0.57721566490153286061, -0.65587807152025388108,
-0.04200263503409523553, 0.16653861138229148950, -0.04219773455554433675,
-0.00962197152787697356, 0.00721894324666309954, -0.00116516759185906511,
-0.00021524167411495097, 0.00012805028238811619, -0.0000201348... | 802Gamma function | 3python | 6ry3w |
stirling <- function(z) sqrt(2*pi/z) * (exp(-1)*z)^z
nemes <- function(z) sqrt(2*pi/z) * (exp(-1)*(z + (12*z - (10*z)^-1)^-1))^z
lanczos <- function(z)
{
if(length(z) > 1)
{
sapply(z, lanczos)
} else
{
g <- 7
p <- c(0.99999999999980993, 676.5203681218851, -1259.1392167224028,
771.... | 802Gamma function | 13r | futdc |
var letters = [Character]()
for i in 97...122 {
let char = Character(UnicodeScalar(i))
letters.append(char)
} | 796Generate lower case ASCII alphabet | 17swift | ckg9t |
sub compose {
my ($f, $g) = @_;
sub {
$f -> ($g -> (@_))
};
}
use Math::Trig;
print compose(sub {sin $_[0]}, \&asin)->(0.5), "\n"; | 806Function composition | 2perl | gwv4e |
ar = %w[17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1]
FractalProgram = ar.map(&:to_r)
Runner = Enumerator.new do |y|
num = 2
loop{ y << num *= FractalProgram.detect{|f| (num*f).denominator == 1} }
end
prime_generator = Enumerator.new do |y|
Ru... | 805Fractran | 14ruby | u1lvz |
<?php
function compose($f, $g) {
return function($x) use ($f, $g) { return $f($g($x)); };
}
$trim_strlen = compose('strlen', 'trim');
echo $result = $trim_strlen(' Test '), ;
?> | 806Function composition | 12php | nl0ig |
class TestFractran extends FunSuite {
val program = Fractran("17/91 78/85 19/51 23/38 29/33 77/29 95/23 77/19 1/17 11/13 13/11 15/14 15/2 55/1")
val expect = List(2, 15, 825, 725, 1925, 2275, 425, 390, 330, 290, 770, 910, 170, 156, 132)
test("find first fifteen fractran figures") {
assert((program .execute(2... | 805Fractran | 16scala | rx5gn |
extension CGFloat {
func degrees_to_radians() -> CGFloat {
return CGFloat(M_PI) * self / 180.0
}
}
extension Double {
func degrees_to_radians() -> Double {
return Double(M_PI) * self / 180.0
}
}
class Tree: UIView {
func drawTree(x1: CGFloat, y1: CGFloat, angle: CGFloat, depth:Int){
if depth ... | 804Fractal tree | 17swift | ic8o0 |
print | 755Hello world/Text | 3python | gqq4h |
$a = [ 1.00000_00000_00000_00000, 0.57721_56649_01532_86061, -0.65587_80715_20253_88108,
-0.04200_26350_34095_23553, 0.16653_86113_82291_48950, -0.04219_77345_55544_33675,
-0.00962_19715_27876_97356, 0.00721_89432_46663_09954, -0.00116_51675_91859_06511,
-0.00021_52416_74114_95097, 0.00012_80502_8... | 802Gamma function | 14ruby | mj9yj |
null | 804Fractal tree | 20typescript | vpl23 |
import java.util.Locale._
object Gamma {
def stGamma(x:Double):Double=math.sqrt(2*math.Pi/x)*math.pow((x/math.E), x)
def laGamma(x:Double):Double={
val p=Seq(676.5203681218851, -1259.1392167224028, 771.32342877765313,
-176.61502916214059, 12.507343278686905, -0.13857109526572012,
... | 802Gamma function | 16scala | 2pvlb |
compose = lambda f, g: lambda x: f( g(x) ) | 806Function composition | 3python | rxugq |
compose <- function(f,g) function(x) { f(g(x)) }
r <- compose(sin, cos)
print(r(.5)) | 806Function composition | 13r | u1cvx |
main(){
print(multiply(1,2));
print(multiply2(1,2));
print(multiply3(1,2));
} | 808Function definition | 18dart | lk3ct |
cat("Hello world!\n") | 755Hello world/Text | 13r | vaa27 |
def compose(f,g)
lambda {|x| f[g[x]]}
end
s = compose(Math.method(:sin), Math.method(:cos))
p s[0.5]
p Math.sin(Math.cos(0.5)) | 806Function composition | 14ruby | js47x |
fn compose<'a,F,G,T,U,V>(f: F, g: G) -> Box<Fn(T) -> V + 'a>
where F: Fn(U) -> V + 'a,
G: Fn(T) -> U + 'a,
{
Box::new(move |x| f(g(x)))
} | 806Function composition | 15rust | h0gj2 |
def compose[A](f: A => A, g: A => A) = { x: A => f(g(x)) }
def add1(x: Int) = x+1
val add2 = compose(add1, add1) | 806Function composition | 16scala | pijbj |
func compose<A,B,C>(f: (B) -> C, g: (A) -> B) -> (A) -> C {
return { f(g($0)) }
}
let sin_asin = compose(sin, asin)
println(sin_asin(0.5)) | 806Function composition | 17swift | 7q5rq |
function compose<T, U, V> (fn1: (input: T) => U, fn2: (input: U) => V){
return function(value: T) {
return fn2(fn1(value))
}
}
function size (s: string): number { return s.length; }
function isEven(x: number): boolean { return x% 2 === 0; }
const evenSize = compose(size, isEven);
console.log(evenSi... | 806Function composition | 20typescript | 8mx0i |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.