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" "sort" )
863Faces from a mesh
0go
qzzxz
import Data.List (find, delete, (\\)) import Control.Applicative ((<|>)) newtype Perimeter a = Perimeter [a] deriving Show instance Eq a => Eq (Perimeter a) where Perimeter p1 == Perimeter p2 = null (p1 \\ p2) && ((p1 `elem` zipWith const (iterate rotate p2) p1) || Perimeter p1 == Perimeter (rev...
863Faces from a mesh
8haskell
mrryf
(1 to 100).filter(_ % 2 == 0)
853Filter
16scala
edlab
use strict; use warnings; use feature 'say'; use Set::Scalar; use Set::Bag; use Storable qw(dclone); sub show { my($pts) = @_; my $p='( '; $p .= '(' . join(' ',@$_) . ') ' for @$pts; $p.')' } sub check_equivalence { my($a, $b) = @_; Set::Scalar->new(@$a) == Set::Scalar->new(@$b) } sub edge_to_periphery { ...
863Faces from a mesh
2perl
4aa5d
package main import ( "fmt" "math" ) type float float64 func (f float) p(e float) float { return float(math.Pow(float64(f), float64(e))) } func main() { ops := []string{"-x.p(e)", "-(x).p(e)", "(-x).p(e)", "-(x.p(e))"} for _, x := range []float{float(-5), float(5)} { for _, e := range []floa...
864Exponentiation with infix operators in (or operating on) the base
0go
6453p
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
835FizzBuzz
2perl
boak4
main = do print [-5^2,-(5)^2,(-5)^2,-(5^2)] print [-5^^2,-(5)^^2,(-5)^^2,-(5^^2)] print [-5**2,-(5)**2,(-5)**2,-(5**2)] print [-5^3,-(5)^3,(-5)^3,-(5^3)] print [-5^^3,-(5)^^3,(-5)^^3,-(5^^3)] print [-5**3,-(5)**3,(-5)**3,-(5**3)]
864Exponentiation with infix operators in (or operating on) the base
8haskell
jqx7g
def perim_equal(p1, p2): if len(p1) != len(p2) or set(p1) != set(p2): return False if any(p2 == (p1[n:] + p1[:n]) for n in range(len(p1))): return True p2 = p2[::-1] return any(p2 == (p1[n:] + p1[:n]) for n in range(len(p1))) def edge_to_periphery(e): edges = sorted(e) p =...
863Faces from a mesh
3python
gee4h
mathtype = math.type or type
864Exponentiation with infix operators in (or operating on) the base
1lua
cj792
int main() { double inf = 1/0.0; double minus_inf = -1/0.0; double minus_zero = -1/ inf ; double nan = 0.0/0.0; printf(,inf); printf(,minus_inf); printf(,minus_zero); printf(,nan); printf(,inf + 2.0); printf(,inf - 10.1); printf(,inf + minus_inf); printf(,0.0 * in...
865Extreme floating point values
5c
wfnec
package main import ( "fmt" "math/rand" "strconv" "strings" "time" ) func factorial(n int) int { fact := 1 for i := 2; i <= n; i++ { fact *= i } return fact } func genFactBaseNums(size int, countOnly bool) ([][]int, int) { var results [][]int count := 0 for n :...
866Factorial base numbers indexing permutations of a collection
0go
wfieg
(def neg-inf (/ -1.0 0.0)) (def inf (/ 1.0 0.0)) (def nan (/ 0.0 0.0)) (def neg-zero (/ -2.0 Double/POSITIVE_INFINITY)) (println " Negative inf: " neg-inf) (println " Positive inf: " inf) (println " NaN: " nan) (println " Negative 0: " neg-zero) (println " inf + -inf: " (+ inf neg-inf)...
865Extreme floating point values
6clojure
8y305
import Data.List (unfoldr, intercalate) newtype Fact = Fact [Int] fact :: [Int] -> Fact fact = Fact . zipWith min [0..] . reverse instance Show Fact where show (Fact ds) = intercalate "." $ show <$> reverse ds toFact :: Integer -> Fact toFact 0 = Fact [0] toFact n = Fact $ unfoldr f (1, n) where f (b, 0) =...
866Factorial base numbers indexing permutations of a collection
8haskell
64v3k
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo ; else if (!($i % 3)) echo ; else if (!($i % 5)) echo ; else echo ; } ?>
835FizzBuzz
12php
6g93g
int main() { int n, b, d; unsigned long long i, j, sum, fact[12]; fact[0] = 1; for (n = 1; n < 12; ++n) { fact[n] = fact[n-1] * n; } for (b = 9; b <= 12; ++b) { printf(, b); for (i = 1; i < 1500000; ++i) { sum = 0; j = i; whil...
867Factorions
5c
lhgcy
use strict; use warnings; use Sub::Infix; BEGIN { *e = infix { $_[0] ** $_[1] } }; my @eqns = ('1 + -$xOP$p', '1 + (-$x)OP$p', '1 + (-($x)OP$p)', '(1 + -$x)OP$p', '1 + -($xOP$p)'); for my $op ('**', '/e/', '|e|') { for ( [-5, 2], [-5, 3], [5, 2], [5, 3] ) { my( $x, $p, $eqn ) = @$_; printf 'x:%2...
864Exponentiation with infix operators in (or operating on) the base
2perl
wfde6
use strict; use warnings; use feature 'say'; sub fpermute { my($f,@a) = @_; my @f = split /\./, $f; for (0..$ my @b = @a[$_ .. $_+$f[$_]]; unshift @b, splice @b, $ @a[$_ .. $_+$f[$_]] = @b; } join '', @a; } sub base { my($n) = @_; my @digits; push(@digits, int ...
866Factorial base numbers indexing permutations of a collection
2perl
uphvr
expressions <- alist(-x ^ p, -(x) ^ p, (-x) ^ p, -(x ^ p)) x <- c(-5, -5, 5, 5) p <- c(2, 3, 2, 3) output <- data.frame(x, p, setNames(lapply(expressions, eval), sapply(expressions, deparse)), check.names = FALSE) print(output, row.names = FALSE)
864Exponentiation with infix operators in (or operating on) the base
13r
1iopn
--Create the original array (table CREATE TABLE DECLARE @n INT SET @n=1 while @n<=10 BEGIN INSERT INTO --Select the subset that are even into the new array (table SELECT v INTO -- Show SELECT * FROM -- Clean up so you can edit and repeat: DROP TABLE DROP TABLE
853Filter
19sql
qzuxb
nums = [-5, 5] pows = [2, 3] nums.product(pows) do |x, p| puts end
864Exponentiation with infix operators in (or operating on) the base
14ruby
s3zqw
import math def apply_perm(omega,fbn): for m in range(len(fbn)): g = fbn[m] if g > 0: new_first = omega[m+g] omega[m+1:m+g+1] = omega[m:m+g] omega[m] = new_first return omega def int_to_fbn(i): ...
866Factorial base numbers indexing permutations of a collection
3python
51kux
from itertools import product xx = '-5 +5'.split() pp = '2 3'.split() texts = '-x**p -(x)**p (-x)**p -(x**p)'.split() print('Integer variable exponentiation') for x, p in product(xx, pp): print(f' x,p = {x:2},{p}; ', end=' ') x, p = int(x), int(p) print('; '.join(f for t in texts)) print('\nBonus intege...
864Exponentiation with infix operators in (or operating on) the base
3python
xtfwr
let numbers = [1,2,3,4,5,6] let even_numbers = numbers.filter { $0% 2 == 0 } println(even_numbers)
853Filter
17swift
k06hx
sub factors { my($n) = @_; return grep { $n % $_ == 0 }(1 .. $n); } print join ' ',factors(64), "\n";
861Factors of an integer
2perl
xt3w8
package main import ( "fmt" "math" ) func main() {
865Extreme floating point values
0go
cjr9g
package main import ( "fmt" "strconv" ) func main() {
867Factorions
0go
xtiwf
import Text.Printf (printf) import Data.List (unfoldr) import Control.Monad (guard) factorion :: Int -> Int -> Bool factorion b n = f b n == n where f b = sum . map (product . enumFromTo 1) . unfoldr (\x -> guard (x > 0) >> pure (x `mod` b, x `div` b)) main :: IO () main = mapM_ (uncurry (printf "Factorions for ba...
867Factorions
8haskell
ygv66
def negInf = -1.0d / 0.0d;
865Extreme floating point values
7groovy
35vzd
main = do let inf = 1/0 let minus_inf = -1/0 let minus_zero = -1/inf let nan = 0/0 putStrLn ("Positive infinity = "++(show inf)) putStrLn ("Negative infinity = "++(show minus_inf)) putStrLn ("Negative zero = "++(show minus_zero)) putStrLn ("Not a number = "++(show nan)) putStrLn ("inf + 2.0 = "++(show (inf+2.0))) p...
865Extreme floating point values
8haskell
po0bt
public class Factorion { public static void main(String [] args){ System.out.println("Base 9:"); for(int i = 1; i <= 1499999; i++){ String iStri = String.valueOf(i); int multiplied = operate(iStri,9); if(multiplied == i){ System.out.print(i + "\t")...
867Factorions
9java
dlyn9
switch(((firsttest)?0:2)+((secondtest)?0:1)) {\ case 0: bothtrue; break;\ case 1: firsttrue; break;\ case 2: secondtrue; break;\ case 3: bothfalse; break;\ }
868Extend your language
5c
zu9tx
int field[CHUNK_BYTES]; typedef unsigned uint; typedef struct { uint *e; uint cap, len; } uarray; uarray primes, offset; void push(uarray *a, uint n) { if (a->len >= a->cap) { if (!(a->cap *= 2)) a->cap = 16; a->e = realloc(a->e, sizeof(uint) * a->cap); ...
869Extensible prime generator
5c
64c32
function GetFactors($n){ $factors = array(1, $n); for($i = 2; $i * $i <= $n; $i++){ if($n % $i == 0){ $factors[] = $i; if($i * $i != $n) $factors[] = $n/$i; } } sort($factors); return $factors; }
861Factors of an integer
12php
2kpl4
public class Extreme { public static void main(String[] args) { double negInf = -1.0 / 0.0;
865Extreme floating point values
9java
rwag0
(defmacro if2 [[cond1 cond2] bothTrue firstTrue secondTrue else] `(let [cond1# ~cond1 cond2# ~cond2] (if cond1# (if cond2# ~bothTrue ~firstTrue) (if cond2# ~secondTrue ~else))))
868Extend your language
6clojure
97uma
use strict; use warnings; use ntheory qw/factorial todigits/; my $limit = 1500000; for my $b (9 .. 12) { print "Factorions in base $b:\n"; $_ == factorial($_) and print "$_ " for 0..$b-1; for my $i (1 .. int $limit/$b) { my $sum; my $prod = $i * $b; for (reverse todigits($i, $b))...
867Factorions
2perl
51hu2
ns test-project-intellij.core (:gen-class) (:require [clojure.string:as string])) (def primes " The following routine produces a infinite sequence of primes (i.e. can be infinite since the evaluation is lazy in that it only produces values as needed). The method is from clojure primes.clj library which pr...
869Extensible prime generator
6clojure
lh5cb
null
865Extreme floating point values
11kotlin
vbh21
local inf=math.huge local minusInf=-math.huge local NaN=0/0 local negativeZeroSorta=-1E-240
865Extreme floating point values
1lua
upkvl
int main() { printf(,pow(pow(5,3),2)); printf(,pow(5,pow(3,2))); return 0; }
870Exponentiation order
5c
lhucy
fact = [1] for n in range(1, 12): fact.append(fact[n-1] * n) for b in range(9, 12+1): print(f) for i in range(1, 1500000): fact_sum = 0 j = i while j > 0: d = j% b fact_sum += fact[d] j = j if fact_sum == i: print(i, end=) ...
867Factorions
3python
4ak5k
import re from typing import Dict from typing import Iterable from typing import List from typing import NamedTuple from typing import Optional from typing import Tuple NOP = 0b000 LDA = 0b001 STA = 0b010 ADD = 0b011 SUB = 0b100 BRZ = 0b101 JMP = 0b110 STP = 0b111 OPCODES = { : NOP, : LDA, : STA, : ...
871Execute Computer/Zero
3python
poabm
(use 'clojure.math.numeric-tower) (expt (expt 5 3) 2) (expt 5 (expt 3 2)) (reduce expt [5 3 2]) (defn rreduce [f coll] (reduce #(f %2 %) (reverse coll))) (rreduce expt [5 3 2])
870Exponentiation order
6clojure
4a75o
$define VERSION 0.6 link options $define DRIGHT 1 $define DLEFT 2 $define DUP 3 $define DDOWN 4 record position(row, col) global dir, ip, ram procedure main(argv) local ch, codespace, col, dp, fn, line local row := 1 local wid := 0 local dirs := [] local ips := [] local opts, verbose, debug...
872Execute SNUSP
5c
f2td3
def factorion?(n, base) n.digits(base).sum{|digit| (1..digit).inject(1,:*)} == n end (9..12).each do |base| puts end
867Factorions
14ruby
rwpgs
Iterable<int> primesMap() { Iterable<int> oddprms() sync* { yield(3); yield(5);
869Extensible prime generator
18dart
ncziq
object Factorion extends App { private def is_factorion(i: Int, b: Int): Boolean = { var sum = 0L var j = i while (j > 0) { sum += f(j % b) j /= b } sum == i } private val f = Array.ofDim[Long](12) f(0) = 1L (1 until 12).foreach(n => ...
867Factorions
16scala
k0whk
package main import "fmt" import "math" func main() { var a, b, c float64 a = math.Pow(5, math.Pow(3, 2)) b = math.Pow(math.Pow(5, 3), 2) c = math.Pow(5, math.Pow(3, 2)) fmt.Printf("5^3^2 =%.0f\n", a) fmt.Printf("(5^3)^2 =%.0f\n", b) fmt.Printf("5^(3^2) =%.0f\n", c) }
870Exponentiation order
0go
xt0wf
var fact = Array(repeating: 0, count: 12) fact[0] = 1 for n in 1..<12 { fact[n] = fact[n - 1] * n } for b in 9...12 { print("The factorions for base \(b) are:") for i in 1..<1500000 { var sum = 0 var j = i while j > 0 { sum += fact[j% b] j /= b } if sum == i { print("\(...
867Factorions
17swift
geb49
println(" 5 ** 3 ** 2 == " + 5**3**2) println("(5 ** 3)** 2 == " + (5**3)**2) println(" 5 **(3 ** 2)== " + 5**(3**2))
870Exponentiation order
7groovy
poebo
>:i (^) (^):: (Num a, Integral b) => a -> b -> a infixr 8 ^ >:i (**) class Fractional a => Floating a where ... (**):: a -> a -> a ... infixr 8 ** >:i (^^) (^^):: (Fractional a, Integral b) => a -> b -> a infixr 8 ^^
870Exponentiation order
8haskell
ygc66
jq -n 'pow(pow(5;3);2)' 15625
870Exponentiation order
9java
dlzn9
null
870Exponentiation order
11kotlin
06isf
for i in xrange(1, 101): if i% 15 == 0: print elif i% 3 == 0: print elif i% 5 == 0: print else: print i
835FizzBuzz
3python
piebm
func fib(a int) int { if a < 2 { return a } return fib(a - 1) + fib(a - 2) }
862Fibonacci sequence
0go
hs0jq
use strict; use warnings; my $nzero = -0.0; my $nan = 0 + "nan"; my $pinf = +"inf"; my $ninf = -"inf"; printf "\$nzero =%.1f\n", $nzero; print "\$nan = $nan\n"; print "\$pinf = $pinf\n"; print "\$ninf = $ninf\n\n"; printf "atan2(0, 0) =%g\n", atan2(0, 0); printf "atan2(0, \$nzero) =%g\n", atan2(0, $nzero); printf "s...
865Extreme floating point values
2perl
06zs4
# # snusp.icn, A Modular SNUSP interpreter # $define VERSION 0.6 # allow a couple of cli options link options # directions $define DRIGHT 1 $define DLEFT 2 $define DUP 3 $define DDOWN 4 record position(row, col) global dir, ip, ram procedure main(argv) local ch, codespace, col, dp, fn, line local row :=...
872Execute SNUSP
0go
jqh7d
print("5^3^2 = " .. 5^3^2) print("(5^3)^2 = " .. (5^3)^2) print("5^(3^2) = " .. 5^(3^2))
870Exponentiation order
1lua
8yn0e
def rFib rFib = { it == 0 ? 0 : it == 1 ? 1 : it > 1 ? rFib(it-1) + rFib(it-2) : rFib(it+2) - rFib(it+1) }
862Fibonacci sequence
7groovy
4ae5f
void runCode(const char *code) { int c_len = strlen(code); int i, bottles; unsigned accumulator=0; for(i=0;i<c_len;i++) { switch(code[i]) { case 'Q': printf(, code); break; case 'H': printf(); br...
873Execute HQ9+
5c
060st
# # snusp.icn, A Modular SNUSP interpreter # $define VERSION 0.6 # allow a couple of cli options link options # directions $define DRIGHT 1 $define DLEFT 2 $define DUP 3 $define DDOWN 4 record position(row, col) global dir, ip, ram procedure main(argv) local ch, codespace, col, dp, fn, line local row :=...
872Execute SNUSP
8haskell
omi8p
>>> def factors(n): return [i for i in range(1, n + 1) if not n%i]
861Factors of an integer
3python
qz6xi
say "$_ = " . eval($_) for qw/5**3**2 (5**3)**2 5**(3**2)/;
870Exponentiation order
2perl
51ru2
import Data.CReal phi = (1 + sqrt 5) / 2 fib :: (Integral b) => b -> CReal 0 fib n = (phi^^n - (-phi)^^(-n))/sqrt 5
862Fibonacci sequence
8haskell
i9cor
int ipow(int base, int exp) { int pow = base; int v = 1; if (exp < 0) { assert (base != 0); return (base*base != 1)? 0: (exp&1)? base : 1; } while(exp > 0 ) { if (exp & 1) v *= pow; pow *= pow; exp >>= 1; } return v; } double dpow(double base, int exp) { dou...
874Exponentiation operator
5c
dcinv
>>> >>> inf = 1e234 * 1e234 >>> _inf = 1e234 * -1e234 >>> _zero = 1 / _inf >>> nan = inf + _inf >>> inf, _inf, _zero, nan (inf, -inf, -0.0, nan) >>> >>> for value in (inf, _inf, _zero, nan): print (value) inf -inf -0.0 nan >>> >>> float('nan') nan >>> float('inf') inf >>> float('-inf') -inf >>> -0. -0.0 >>> >>> na...
865Extreme floating point values
3python
8y30o
1/c(0, -0, Inf, -Inf, NaN)
865Extreme floating point values
13r
xtdw2
const echo2 = raw""" /==!/======ECHO==,==.==# | | $==>==@/==@/==<==#""" @enum Direction left up right down function snusp(datalength, progstring) stack = Vector{Tuple{Int, Int, Direction}}() data = zeros(datalength) dp = ipx = ipy = 1 direction = right # default to go to right at b...
872Execute SNUSP
9java
wfxej
const echo2 = raw""" /==!/======ECHO==,==.==# | | $==>==@/==@/==<==#""" @enum Direction left up right down function snusp(datalength, progstring) stack = Vector{Tuple{Int, Int, Direction}}() data = zeros(datalength) dp = ipx = ipy = 1 direction = right # default to go to right at b...
872Execute SNUSP
10javascript
8yo0l
>>> 5**3**2 1953125 >>> (5**3)**2 15625 >>> 5**(3**2) 1953125 >>> >>> try: from functools import reduce except: pass >>> reduce(pow, (5, 3, 2)) 15625 >>>
870Exponentiation order
3python
4a75k
print(quote(5**3)) print(quote(5^3))
870Exponentiation order
13r
2k5lg
xx <- x <- 1:100 xx[x %% 3 == 0] <- "Fizz" xx[x %% 5 == 0] <- "Buzz" xx[x %% 15 == 0] <- "FizzBuzz" xx
835FizzBuzz
13r
jsb78
package main import ( "container/heap" "fmt" ) func main() { p := newP() fmt.Print("First twenty: ") for i := 0; i < 20; i++ { fmt.Print(p(), " ") } fmt.Print("\nBetween 100 and 150: ") n := p() for n <= 100 { n = p() } for ; n < 150; n = p() { fmt.P...
869Extensible prime generator
0go
powbg
factors <- function(n) { if(length(n) > 1) { lapply(as.list(n), factors) } else { one.to.n <- seq_len(n) one.to.n[(n %% one.to.n) == 0] } }
861Factors of an integer
13r
anf1z
(ns anthony.random.hq9plus (:require [clojure.string:as str])) (defn bottles [] (loop [bottle 99] (if (== bottle 0) () (do (println (str bottle " bottles of beer on the wall")) (println (str bottle " bottles of beer")) (println "Take one down, pass it around") (print...
873Execute HQ9+
6clojure
dldnb
long hailstone(long, long**); void free_sequence(long *);
875Executable library
5c
enpav
. clojure.jar rosetta_code frequent_hailstone_lengths.clj hailstone_sequence.clj
875Executable library
6clojure
03xsj
null
872Execute SNUSP
11kotlin
b8pkb
#!/usr/bin/env runghc import Data.List import Data.Numbers.Primes import System.IO firstNPrimes :: Integer -> [Integer] firstNPrimes n = genericTake n primes primesBetweenInclusive :: Integer -> Integer -> [Integer] primesBetweenInclusive lo hi = dropWhile (< lo) $ takeWhile (<= hi) primes nthPrime :: Integer -> ...
869Extensible prime generator
8haskell
f26d1
null
875Executable library
0go
9r6mt
import strutils # Requires 5 bytes of data store. const Hw = r""" /++++!/===========?\>++.>+.+++++++..+++\ \+++\ | /+>+++++++>/ /++++++++++<<.++>./ $+++/ | \+++++++++>\ \+++++.>.+++.
872Execute SNUSP
1lua
po1bw
package main import "fmt" type F func() type If2 struct {cond1, cond2 bool} func (i If2) else1(f F) If2 { if i.cond1 && !i.cond2 { f() } return i } func (i If2) else2(f F) If2 { if i.cond2 && !i.cond1 { f() } return i } func (i If2) else0(f F) If2 { if !i.cond1 && !i.co...
868Extend your language
0go
k0ehz
ar = [, , , ] ar.each{|exp| puts }
870Exponentiation order
14ruby
rwhgs
(defn ** [x n] (reduce * (repeat n x)))
874Exponentiation operator
6clojure
65z3q
inf = 1.0 / 0.0 nan = 0.0 / 0.0 expression = [ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ] expression.each do |exp| puts % [exp, eval(exp)] end
865Extreme floating point values
14ruby
i9yoh
with javascript_semantics integer id = 0, ipr = 1, ipc = 1 procedure step() if and_bits(id,1) == 0 then ipc += 1 - and_bits(id,2) else ipr += 1 - and_bits(id,2) end if end procedure procedure snusp(integer dlen, string s) sequence ds = repeat(0,dlen) -- data store integer dp = ...
872Execute SNUSP
2perl
64y36
if2 :: Bool -> Bool -> a -> a -> a -> a -> a if2 p1 p2 e12 e1 e2 e = if p1 then if p2 then e12 else e1 else if p2 then e2 else e main = print $ if2 True False (error "TT") "TF" (error "FT") (error "FF")
868Extend your language
8haskell
nc3ie
fn main() { println!("5**3**2 = {:7}", 5u32.pow(3).pow(2)); println!("(5**3)**2 = {:7}", (5u32.pow(3)).pow(2)); println!("5**(3**2) = {:7}", 5u32.pow(3u32.pow(2))); }
870Exponentiation order
15rust
7xkrc
$ include "seed7_05.s7i"; const proc: main is func begin writeln("5**3**2 = " <& 5**3**2); writeln("(5**3)**2 = " <& (5**3)**2); writeln("5**(3**2) = " <& 5**(3**2)); end func;
870Exponentiation order
16scala
k01hk
import java.util.ArrayList; import java.util.List;
875Executable library
9java
gau4m
fn main() { let inf: f64 = 1. / 0.;
865Extreme floating point values
15rust
ncmi4
precedencegroup ExponentiationPrecedence { associativity: left higherThan: MultiplicationPrecedence } infix operator **: ExponentiationPrecedence @inlinable public func ** <T: BinaryInteger>(lhs: T, rhs: T) -> T { guard lhs!= 0 else { return 1 } var x = lhs var n = rhs var y = T(1) while n > 1 {...
870Exponentiation order
17swift
gej49
import java.util.*; public class PrimeGenerator { private int limit_; private int index_ = 0; private int increment_; private int count_ = 0; private List<Integer> primes_ = new ArrayList<>(); private BitSet sieve_ = new BitSet(); private int sieveLimit_ = 0; public PrimeGenerator(int ...
869Extensible prime generator
9java
06nse
typedef struct exception { int extype; char what[128]; } exception; typedef struct exception_ctx { exception * exs; int size; int pos; } exception_ctx; exception_ctx * Create_Ex_Ctx(int length) { const int safety = 8; char * tmp = (char*) malloc(safety+sizeof(e...
876Exceptions/Catch an exception thrown in a nested call
5c
xf1wu
#!/usr/bin/env luajit bit32=bit32 or bit local lib={ hailstone=function(n) local seq={n} while n>1 do n=bit32.band(n,1)==1 and 3*n+1 or n/2 seq[#seq+1]=n end return seq end } if arg[0] and arg[0]:match("hailstone.lua") then local function printf(fmt, ...) io.write(string.format(fmt, ...)) end local ...
875Executable library
1lua
vkc2x
object ExtremeFloatingPoint extends App { val negInf = -1.0 / 0.0
865Extreme floating point values
16scala
tvlfb
HW = r''' /++++!/===========?\>++.>+.+++++++..+++\ \+++\ | /+>+++++++>/ /++++++++++<<.++>./ $+++/ | \+++++++++>\ \+++++.>.+++.-----\ \==-<<<<+>+++/ /=.>.+>.--------.-/''' def snusp(store, code): ds = bytearray(store) dp = 0 cs = code.splitlines() ipr, ipc = 0, 0 fo...
872Execute SNUSP
3python
ygm6q
function primeGenerator(num, showPrimes) { var i, arr = []; function isPrime(num) {
869Extensible prime generator
10javascript
dl3nu
public class If2 { public static void if2(boolean firstCondition, boolean secondCondition, Runnable bothTrue, Runnable firstTrue, Runnable secondTrue, Runnable noneTrue) { if (firstCondition) if (secondCondition) bothTrue.run(); else firstT...
868Extend your language
9java
qzixa
(def U0 (ex-info "U0" {})) (def U1 (ex-info "U1" {})) (defn baz [x] (if (= x 0) (throw U0) (throw U1))) (defn bar [x] (baz x)) (defn foo [] (dotimes [x 2] (try (bar x) (catch clojure.lang.ExceptionInfo e (if (= e U0) (println "foo caught U0") (throw e)))))) (defn -main...
876Exceptions/Catch an exception thrown in a nested call
6clojure
oyq8j