code
stringlengths
1
46.1k
label
class label
1.18k classes
domain_label
class label
21 classes
index
stringlengths
4
5
(defn cfrac [a b n] (letfn [(cfrac-iter [[x k]] [(+ (a k) (/ (b (inc k)) x)) (dec k)])] (ffirst (take 1 (drop (inc n) (iterate cfrac-iter [1 n])))))) (def sq2 (cfrac #(if (zero? %) 1.0 2.0) (constantly 1.0) 100)) (def e (cfrac #(if (zero? %) 2.0 %) #(if (= 1 %) 1.0 (double (dec %))) 100)) (def pi (cfrac #(if (...
1,001Continued fraction
6clojure
bxikz
use strict; use warnings; use feature 'say'; use ntheory 'primes'; use List::AllUtils <indexes max>; my $limit = 1000000; my @primes = @{primes( $limit )}; sub runs { my($op) = @_; my @diff = my $diff = my $run = 1; push @diff, map { my $next = $primes[$_] - $primes[$_ - 1]; if ($op eq '>...
1,000Consecutive primes with ascending or descending differences
2perl
95kmn
class Foodbox def initialize (*food) raise ArgumentError, unless food.all?{|f| f.respond_to?(:eat)} @box = food end end class Fruit def eat; end end class Apple < Fruit; end p Foodbox.new(Fruit.new, Apple.new) p Foodbox.new(Apple.new, )
999Constrained genericity
14ruby
dy5ns
null
999Constrained genericity
15rust
fm4d6
type Eatable = { def eat: Unit } class FoodBox(coll: List[Eatable]) case class Fish(name: String) { def eat { println("Eating "+name) } } val foodBox = new FoodBox(List(new Fish("salmon")))
999Constrained genericity
16scala
3l7zy
typedef struct tPoint { int x, y; } Point; bool ccw(const Point *a, const Point *b, const Point *c) { return (b->x - a->x) * (c->y - a->y) > (b->y - a->y) * (c->x - a->x); } int comparePoints(const void *lhs, const void *rhs) { const Point* lp = lhs; const Point* rp = rhs; if (lp->x < rp-...
1,002Convex hull
5c
8tm04
protocol Eatable { func eat() }
999Constrained genericity
17swift
n6uil
from sympy import sieve primelist = list(sieve.primerange(2,1000000)) listlen = len(primelist) pindex = 1 old_diff = -1 curr_list=[primelist[0]] longest_list=[] while pindex < listlen: diff = primelist[pindex] - primelist[pindex-1] if diff > old_diff: curr_list.append(primelist[pindex]) i...
1,000Consecutive primes with ascending or descending differences
3python
c4b9q
src := "Hello" dst := src
997Copy a string
0go
ozu8q
def string = 'Scooby-doo-bee-doo'
997Copy a string
7groovy
xi9wl
require limit = 1_000_000 puts p Prime.each(limit).each_cons(2).chunk_while{|(i1,i2), (j1,j2)| j1-i1 < j2-i2 }.max_by(&:size).flatten.uniq puts p Prime.each(limit).each_cons(2).chunk_while{|(i1,i2), (j1,j2)| j1-i1 > j2-i2 }.max_by(&:size).flatten.uniq
1,000Consecutive primes with ascending or descending differences
14ruby
2r1lw
null
1,000Consecutive primes with ascending or descending differences
15rust
v7a2t
src = "Hello World" dst = src
997Copy a string
8haskell
2rwll
inline int randn(int m) { int rand_max = RAND_MAX - (RAND_MAX % m); int r; while ((r = rand()) > rand_max); return r / (rand_max / m); } int main() { int i, x, y, r2; unsigned long buf[31] = {0}; for (i = 0; i < 100; ) { x = randn(31) - 15; y = randn(31) - 15; r2 = x * x + y * y; if (r2 >= 100 && r2 <...
1,003Constrained random points on a circle
5c
sd3q5
String src = "Hello"; String newAlias = src; String strCopy = new String(src);
997Copy a string
9java
62k3z
var container = {myString: "Hello"}; var containerCopy = container;
997Copy a string
10javascript
lgecf
(ns rosettacode.circle-random-points (:import [java.awt Color Graphics Dimension] [javax.swing JFrame JPanel])) (let [points (->> (for [x (range -15 16), y (range -15 16) :when (<= 10 (Math/hypot x y) 15)] [(+ x 15) (+ y 15)]) shuffle (take 100))] (doto (JFrame.) (.add (doto (proxy ...
1,003Constrained random points on a circle
6clojure
n6cik
package main import ( "fmt" "rcu" "strconv" "strings" ) func main() { count := 0 k := 11 * 11 var res []int for count < 20 { if k%3 == 0 || k%5 == 0 || k%7 == 0 { k += 2 continue } factors := rcu.PrimeFactors(k) if len(factors) > ...
1,004Composite numbers k with no single digit factors whose factors are all substrings of k
0go
4k152
use strict; use warnings; use ntheory qw<is_prime factor gcd>; my($values,$cnt); LOOP: for (my $k = 11; $k < 1E10; $k += 2) { next if 1 < gcd($k,2*3*5*7) or is_prime $k; map { next if index($k, $_) < 0 } factor $k; $values .= sprintf "%10d", $k; last LOOP if ++$cnt == 20; } print $values =~ s/.{1,100}\...
1,004Composite numbers k with no single digit factors whose factors are all substrings of k
2perl
fmld7
val s = "Hello" val alias = s
997Copy a string
11kotlin
dygnz
package main import ( "fmt" "image" "sort" )
1,002Convex hull
0go
5haul
package main import "fmt" func main(){ fmt.Println(TimeStr(7259)) fmt.Println(TimeStr(86400)) fmt.Println(TimeStr(6000000)) } func TimeStr(sec int)(res string){ wks, sec := sec / 604800,sec % 604800 ds, sec := sec / 86400, sec % 86400 hrs, sec := sec / 3600, sec % 3600 mins, sec := sec / 60, sec % 60 CommaRe...
998Convert seconds to compound duration
0go
8t20g
package main import "fmt" type cfTerm struct { a, b int }
1,001Continued fraction
0go
n62i1
class ConvexHull { private static class Point implements Comparable<Point> { private int x, y Point(int x, int y) { this.x = x this.y = y } @Override int compareTo(Point o) { return Integer.compare(x, o.x) } @Override ...
1,002Convex hull
7groovy
c4h9i
import Control.Monad (forM_) import Data.List (intercalate, mapAccumR) import System.Environment (getArgs) import Text.Printf (printf) import Text.Read (readMaybe) reduceBy :: Integral a => a -> [a] -> [a] n `reduceBy` xs = n': ys where (n', ys) = mapAccumR quotRem n xs durLabs :: [(Integer, String)] durLabs = [(und...
998Convert seconds to compound duration
8haskell
lgach
import java.util.function.Function import static java.lang.Math.pow class Test { static double calc(Function<Integer, Integer[]> f, int n) { double temp = 0 for (int ni = n; ni >= 1; ni--) { Integer[] p = f.apply(ni) temp = p[1] / (double) (p[0] + temp) } r...
1,001Continued fraction
7groovy
sdyq1
import Data.List (sortBy, groupBy, maximumBy) import Data.Ord (comparing) (x, y) = ((!! 0), (!! 1)) compareFrom :: (Num a, Ord a) => [a] -> [a] -> [a] -> Ordering compareFrom o l r = compare ((x l - x o) * (y r - y o)) ((y l - y o) * (x r - x o)) distanceFrom :: Floating a => [a] -> [a] -> a distanceFrom f...
1,002Convex hull
8haskell
xizw4
import Data.List (unfoldr) import Data.Char (intToDigit) sqrt2, napier, myPi :: [(Integer, Integer)] sqrt2 = zip (1: [2,2 ..]) [1,1 ..] napier = zip (2: [1 ..]) (1: [1 ..]) myPi = zip (3: [6,6 ..]) ((^ 2) <$> [1,3 ..]) approxCF :: (Integral a, Fractional b) => Int -> [(a, a)] -> b approxCF t = foldr (\(a, b) ...
1,001Continued fraction
8haskell
ujav2
public class CompoundDuration { public static void main(String[] args) { compound(7259); compound(86400); compound(6000_000); } private static void compound(long seconds) { StringBuilder sb = new StringBuilder(); seconds = addUnit(sb, seconds, 604800, " wk, "); ...
998Convert seconds to compound duration
9java
3ljzg
(function () { 'use strict';
998Convert seconds to compound duration
10javascript
c419j
typedef struct { int rows, cols; complex **z; } matrix; matrix transpose (matrix a) { int i, j; matrix b; b.rows = a.cols; b.cols = a.rows; b.z = malloc (b.rows * sizeof (complex *)); for (i = 0; i < b.rows; i++) { b.z[i] = malloc (b.cols * sizeof (complex)); for (j = 0; j < b.cols; ...
1,005Conjugate transpose
5c
1s8pj
import static java.lang.Math.pow; import java.util.*; import java.util.function.Function; public class Test { static double calc(Function<Integer, Integer[]> f, int n) { double temp = 0; for (int ni = n; ni >= 1; ni--) { Integer[] p = f.apply(ni); temp = p[1] / (double) (p[...
1,001Continued fraction
9java
mujym
a = "string" b = a print(a == b)
997Copy a string
1lua
fmrdp
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import static java.util.Collections.emptyList; public class ConvexHull { private static class Point implements Comparable<Point> { private int x, y; public Point(int x, int y) { ...
1,002Convex hull
9java
bxok3
fun compoundDuration(n: Int): String { if (n < 0) return ""
998Convert seconds to compound duration
11kotlin
n65ij
null
1,001Continued fraction
11kotlin
t95f0
function convexHull(points) { points.sort(comparison); var L = []; for (var i = 0; i < points.length; i++) { while (L.length >= 2 && cross(L[L.length - 2], L[L.length - 1], points[i]) <= 0) { L.pop(); } L.push(points[i]); } var U = []; for (var i = points.leng...
1,002Convex hull
10javascript
wote2
function duration (secs) local units, dur = {"wk", "d", "hr", "min"}, "" for i, v in ipairs({604800, 86400, 3600, 60}) do if secs >= v then dur = dur .. math.floor(secs / v) .. " " .. units[i] .. ", " secs = secs % v end end if secs == 0 then return dur:s...
998Convert seconds to compound duration
1lua
dy4nq
function calc(fa, fb, expansions) local a = 0.0 local b = 0.0 local r = 0.0 local i = expansions while i > 0 do a = fa(i) b = fb(i) r = b / (a + r) i = i - 1 end a = fa(0) return a + r end function sqrt2a(n) if n ~= 0 then return 2.0 else ...
1,001Continued fraction
1lua
zc4ty
pthread_mutex_t condm = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; int bang = 0; pthread_mutex_lock(&condm); \ while( bang == 0 ) \ { \ pthread_cond_wait(&cond, &condm); \ } \ pthread_mutex_unlock(&condm); } while(0);\ void *t_enjoy(void *p) { WAITBANG(); prin...
1,006Concurrent computing
5c
t9cf4
null
1,002Convex hull
11kotlin
rpxgo
function print_point(p) io.write("("..p.x..", "..p.y..")") return nil end function print_points(pl) io.write("[") for i,p in pairs(pl) do if i>1 then io.write(", ") end print_point(p) end io.write("]") return nil end function ccw(a,b,c) return (b.x -...
1,002Convex hull
1lua
71qru
(doseq [text ["Enjoy" "Rosetta" "Code"]] (future (println text)))
1,006Concurrent computing
6clojure
mu5yq
package main import ( "fmt" "math" "math/cmplx" )
1,005Conjugate transpose
0go
yv564
package main import ( "bytes" "fmt" "math/rand" "time" ) const ( nPts = 100 rMin = 10 rMax = 15 ) func main() { rand.Seed(time.Now().Unix()) span := rMax + 1 + rMax rows := make([][]byte, span) for r := range rows { rows[r] = bytes.Repeat([]byte{' '}, span*2) }...
1,003Constrained random points on a circle
0go
v7b2m
import Data.Complex (Complex(..), conjugate) import Data.List (transpose) type Matrix a = [[a]] main :: IO () main = mapM_ (\a -> do putStrLn "\nMatrix:" mapM_ print a putStrLn "Conjugate Transpose:" mapM_ print (conjTranspose a) putStrLn $ "Hermitian? " ++ show (isHermitianMa...
1,005Conjugate transpose
8haskell
hexju
import Data.List import Control.Monad import Control.Arrow import Rosetta.Knuthshuffle task = do let blanco = replicate (31*31) " " cs = sequence [[-15,-14..15],[-15,-14..15]] :: [[Int]] constraint = uncurry(&&).((<= 15*15) &&& (10*10 <=)). sum. map (join (*)) pts <- knuthShuffle $ filter constraint ...
1,003Constrained random points on a circle
8haskell
e8dai
use strict; use warnings; sub compound_duration { my $sec = shift; no warnings 'numeric'; return join ', ', grep { $_ > 0 } int($sec/60/60/24/7) . " wk", int($sec/60/60/24) % 7 . " d", int($sec/60/60) % 24 . " hr", int($sec/60) % 60 . " min", int($sec) ...
998Convert seconds to compound duration
2perl
71orh
use strict; use warnings; no warnings 'recursion'; use experimental 'signatures'; sub continued_fraction ($a, $b, $n = 100) { $a->() + ($n and $b->() / continued_fraction($a, $b, $n-1)); } printf "2 %.9f\n", continued_fraction do { my $n; sub { $n++ ? 2 : 1 } }, sub { 1 }; printf "e...
1,001Continued fraction
2perl
kwohc
import 'dart:math' show Random; main(){ enjoy() .then( (e) => print(e) ); rosetta() .then( (r) => print(r) ); code() .then( (c) => print(c) ); }
1,006Concurrent computing
18dart
8tz0y
null
1,005Conjugate transpose
11kotlin
c4r98
typedef struct Point { int x; int y; } Point;
1,007Compound data type
5c
2rrlo
(defrecord Point [x y])
1,007Compound data type
6clojure
gbb4f
import java.util.Random; public class FuzzyCircle { static final Random rnd = new Random(); public static void main(String[] args){ char[][] field = new char[31][31]; for(int i = 0; i < field.length; i++){ for(int j = 0; j < field[i].length; j++){ field[i][j] = ' '; } } int pointsInDisc = 0; whil...
1,003Constrained random points on a circle
9java
hesjm
use strict; use English; use Math::Complex; use Math::MatrixReal; my @examples = (example1(), example2(), example3()); foreach my $m (@examples) { print "Starting matrix:\n", cmat_as_string($m), "\n"; my $m_ct = conjugate_transpose($m); print "Its conjugate transpose:\n", cmat_as_string($m_ct), "\n"; p...
1,005Conjugate transpose
2perl
xidw8
<html><head><title>Circle</title></head> <body> <canvas id="cv" width="320" height="320"></canvas> <script type="application/javascript"> var cv = document.getElementById('cv'); var ctx = cv.getContext('2d'); var w = cv.width; var h = cv.height;
1,003Constrained random points on a circle
10javascript
a0n10
>>> def duration(seconds): t= [] for dm in (60, 60, 24, 7): seconds, m = divmod(seconds, dm) t.append(m) t.append(seconds) return ', '.join('%d%s'% (num, unit) for num, unit in zip(t[::-1], 'wk d hr min sec'.split()) if num) >>> for seconds in [7259, 86400, 6000000]: print(% (seconds, duration(seconds...
998Convert seconds to compound duration
3python
jai7p
from fractions import Fraction import itertools try: zip = itertools.izip except: pass def CF(a, b, t): terms = list(itertools.islice(zip(a, b), t)) z = Fraction(1,1) for a, b in reversed(terms): z = a + b / z return z def pRes(x, d): q, x = divmod(x, 1) res = str(q) res += for i in range(d): ...
1,001Continued fraction
3python
bxikr
null
1,003Constrained random points on a circle
11kotlin
4ka57
use strict; use warnings; use feature 'say'; { package Point; use Class::Struct; struct( x => '$', y => '$',); sub print { '(' . $_->x . ', ' . $_->y . ')' } } sub ccw { my($a, $b, $c) = @_; ($b->x - $a->x)*($c->y - $a->y) - ($b->y - $a->y)*($c->x - $a->x); } sub tangent { my($a, $b) = @_; my $opp = ...
1,002Convex hull
2perl
dy2nw
def conjugate_transpose(m): return tuple(tuple(n.conjugate() for n in row) for row in zip(*m)) def mmul( ma, mb): return tuple(tuple(sum( ea*eb for ea,eb in zip(a,b)) for b in zip(*mb)) for a in ma) def mi(size): 'Complex Identity matrix' sz = range(size) m = [[0 + 0j for i in sz] for j in sz] ...
1,005Conjugate transpose
3python
qnfxi
package main import ( "fmt" "golang.org/x/exp/rand" "time" ) func main() { words := []string{"Enjoy", "Rosetta", "Code"} seed := uint64(time.Now().UnixNano()) q := make(chan string) for i, w := range words { go func(w string, seed uint64) { r := rand.New(rand.NewSource(...
1,006Concurrent computing
0go
hewjq
my $original = 'Hello.'; my $new = $original; $new = 'Goodbye.'; print "$original\n";
997Copy a string
2perl
jan7f
from __future__ import print_function from shapely.geometry import MultiPoint if __name__==: pts = MultiPoint([(16,3), (12,17), (0,6), (-4,-6), (16,6), (16,-7), (16,-3), (17,-4), (5,19), (19,-8), (3,16), (12,13), (3,-4), (17,5), (-3,15), (-3,-9), (0,11), (-9,-3), (-4,-2), (12,10)]) print (pts.convex_hull)
1,002Convex hull
3python
fmvde
'Enjoy Rosetta Code'.tokenize().collect { w -> Thread.start { Thread.sleep(1000 * Math.random() as int) println w } }.each { it.join() }
1,006Concurrent computing
7groovy
4kb5f
import Control.Concurrent main = mapM_ forkIO [process1, process2, process3] where process1 = putStrLn "Enjoy" process2 = putStrLn "Rosetta" process3 = putStrLn "Code"
1,006Concurrent computing
8haskell
i36or
require 'bigdecimal' sqrt2 = Object.new def sqrt2.a(n); n == 1? 1: 2; end def sqrt2.b(n); 1; end napier = Object.new def napier.a(n); n == 1? 2: n - 1; end def napier.b(n); n == 1? 1: n - 1; end pi = Object.new def pi.a(n); n == 1? 3: 6; end def pi.b(n); (2*n - 1)**2; end def estimate(cfrac, prec) last_resul...
1,001Continued fraction
14ruby
1sdpw
$src = ; $dst = $src;
997Copy a string
12php
t97f1
MINUTE = 60 HOUR = MINUTE*60 DAY = HOUR*24 WEEK = DAY*7 def sec_to_str(sec) w, rem = sec.divmod(WEEK) d, rem = rem.divmod(DAY) h, rem = rem.divmod(HOUR) m, s = rem.divmod(MINUTE) units = [, , , , ] units.reject{|str| str.start_with?()}.join() end [7259, 86400, 6000000].each{|t| puts }
998Convert seconds to compound duration
14ruby
kwdhg
require 'matrix' i = Complex::I matrix = Matrix[[i, 0, 0], [0, i, 0], [0, 0, i]] conjt = matrix.conj.t print 'conjugate tranpose: '; puts conjt if matrix.square? print 'Hermitian? '; puts matrix.hermitian? print ' normal? '; puts matrix.normal? print ' unitar...
1,005Conjugate transpose
14ruby
0fzsu
use std::iter;
1,001Continued fraction
15rust
a0f14
t, n = {}, 0 for y=1,31 do t[y]={} for x=1,31 do t[y][x]=" " end end repeat x, y = math.random(-15,15), math.random(-15,15) rsq = x*x + y*y if rsq>=100 and rsq<=225 and t[y+16][x+16]==" " then t[y+16][x+16], n = "", n+1 end until n==100 for y=1,31 do print(table.concat(t[y])) end
1,003Constrained random points on a circle
1lua
gbe4j
use std::fmt; struct CompoundTime { w: usize, d: usize, h: usize, m: usize, s: usize, } macro_rules! reduce { ($s: ident, $(($from: ident, $to: ident, $factor: expr)),+) => {{ $( $s.$to += $s.$from / $factor; $s.$from%= $factor; )+ }} } impl Compou...
998Convert seconds to compound duration
15rust
bxfkx
import java.util.concurrent.CyclicBarrier; public class Threads { public static class DelayedMessagePrinter implements Runnable { private CyclicBarrier barrier; private String msg; public DelayedMessagePrinter(CyclicBarrier barrier, String msg) { this.barrier = barrier; this.msg = msg;...
1,006Concurrent computing
9java
xinwy
self.addEventListener('message', function (event) { self.postMessage(event.data); self.close(); }, false);
1,006Concurrent computing
10javascript
oz386
extern crate num;
1,005Conjugate transpose
15rust
8t307
object ConjugateTranspose { case class Complex(re: Double, im: Double) { def conjugate(): Complex = Complex(re, -im) def +(other: Complex) = Complex(re + other.re, im + other.im) def *(other: Complex) = Complex(re * other.re - im * other.im, re * other.im + im * other.re) override def toString(): Str...
1,005Conjugate transpose
16scala
n6mic
object CF extends App { import Stream._ val sqrt2 = 1 #:: from(2,0) zip from(1,0) val napier = 2 #:: from(1) zip (1 #:: from(1)) val pi = 3 #:: from(6,0) zip (from(1,2) map {x=>x*x})
1,001Continued fraction
16scala
xi3wg
null
998Convert seconds to compound duration
16scala
a031n
null
1,006Concurrent computing
11kotlin
pqsb6
8fn(8X, 8seq_fold(8times, 1, 8seq_iota(1, 8inc(8X)))) ) int main(void) { printf(, ORDER_PP( 8to_lit( 8fac(10) ) ) ); return 0; }
1,008Compile-time calculation
5c
pqxby
class Point include Comparable attr :x, :y def initialize(x, y) @x = x @y = y end def <=>(other) x <=> other.x end def to_s % [@x, @y] end def to_str to_s() end end def ccw(a, b, c) ((b.x - a.x) * (c.y - a.y)) > ((b.y - a.y) * (c....
1,002Convex hull
14ruby
zc5tw
co = {} co[1] = coroutine.create( function() print "Enjoy" end ) co[2] = coroutine.create( function() print "Rosetta" end ) co[3] = coroutine.create( function() print "Code" end ) math.randomseed( os.time() ) h = {} i = 0 repeat j = math.random(3) if h[j] == nil then coroutine.resume( co[j] ) h[j...
1,006Concurrent computing
1lua
1s0po
(defn fac [n] (apply * (range 1 (inc n)))) (defmacro ct-factorial [n] (fac n))
1,008Compile-time calculation
6clojure
xiowk
extension BinaryInteger { @inlinable public func power(_ n: Self) -> Self { return stride(from: 0, to: n, by: 1).lazy.map({_ in self }).reduce(1, *) } } public struct CycledSequence<WrappedSequence: Sequence> { private var seq: WrappedSequence private var iter: WrappedSequence.Iterator init(seq: Wrapp...
1,001Continued fraction
17swift
pqnbl
>>> src = >>> a = src >>> b = src[:] >>> import copy >>> c = copy.copy(src) >>> d = copy.deepcopy(src) >>> src is a is b is c is d True
997Copy a string
3python
hedjw
#[derive(Debug, Clone)] struct Point { x: f32, y: f32 } fn calculate_convex_hull(points: &Vec<Point>) -> Vec<Point> {
1,002Convex hull
15rust
3l4z8
func duration (_ secs:Int) -> String { if secs <= 0 { return "" } let units = [(604800,"wk"), (86400,"d"), (3600,"hr"), (60,"min")] var secs = secs var result = "" for (period, unit) in units { if secs >= period { result += "\(secs/period) \(unit), " secs = secs% pe...
998Convert seconds to compound duration
17swift
henj0
type point struct { x, y float64 }
1,007Compound data type
0go
qnnxz
str1 <- "abc" str2 <- str1
997Copy a string
13r
gb847
object convex_hull{ def get_hull(points:List[(Double,Double)], hull:List[(Double,Double)]):List[(Double,Double)] = points match{ case Nil => join_tail(hull,hull.size -1) case head :: tail => get_hull(tail,reduce(head::hull)) } def reduce(hull:List[(Double,Double)]):List[(Doubl...
1,002Convex hull
16scala
mu7yc
class Point { int x int y
1,007Compound data type
7groovy
1ssp6
data Tree = Empty | Leaf Int | Node Tree Tree deriving (Eq, Show) t1 = Node (Leaf 1) (Node (Leaf 2) (Leaf 3))
1,007Compound data type
8haskell
muuyf
package main import "fmt" func main() { fmt.Println(2*3*4*5*6*7*8*9*10) }
1,008Compile-time calculation
0go
62l3p
module Factorial where import Language.Haskell.TH.Syntax fact n = product [1..n] factQ :: Integer -> Q Exp factQ = lift . fact
1,008Compile-time calculation
8haskell
ja17g
null
1,008Compile-time calculation
11kotlin
95umh
local factorial = 10*9*8*7*6*5*4*3*2*1 print(factorial)
1,008Compile-time calculation
1lua
c4592
public class Point { public int x, y; public Point() { this(0); } public Point(int x0) { this(x0,0); } public Point(int x0, int y0) { x = x0; y = y0; } public static void main(String args[]) { Point point = new Point(1,2); System.out.println("x = " + point.x ); System.out.println("y = " + point...
1,007Compound data type
9java
fmmdv
my @points; while (@points < 100) { my ($x, $y) = (int(rand(31))-15, int(rand(31)) - 15); my $r2 = $x*$x + $y*$y; next if $r2 < 100 || $r2 > 225; push @points, [$x, $y]; } print << 'HEAD'; %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox 0 0 400 400 200 200 translate 10 10 scale 0 setlinewidth 1 0...
1,003Constrained random points on a circle
2perl
i39o3
null
1,007Compound data type
10javascript
yvv6r