task_url
stringlengths
30
116
task_name
stringlengths
2
86
task_description
stringlengths
0
14.4k
language_url
stringlengths
2
53
language_name
stringlengths
1
52
code
stringlengths
0
61.9k
http://rosettacode.org/wiki/Undefined_values
Undefined values
#Lingo
Lingo
put var -- <Void> put var=VOID -- 1 put voidP(var) -- 1 var = 23 put voidP(var) -- 0
http://rosettacode.org/wiki/Undefined_values
Undefined values
#Logo
Logo
; procedures to square :x output :x * :x end   show defined? "x  ; true show procedure? "x  ; true (also works for built-in primitives) erase "x show defined? "x  ; false show square 3  ; I don't know how to square   ; names   make "n 23   show name? "n  ; true ern "n show name? "n  ; false show :n  ; n h...
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#C
C
#include <stdio.h> #include <stdlib.h> #include <locale.h>   /* wchar_t is the standard type for wide chars; what it is internally * depends on the compiler. */ wchar_t poker[] = L"♥♦♣♠"; wchar_t four_two[] = L"\x56db\x5341\x4e8c";   int main() { /* Set the locale to alert C's multibyte output routines */ if ...
http://rosettacode.org/wiki/Ultra_useful_primes
Ultra useful primes
An ultra-useful prime is a member of the sequence where each a(n) is the smallest positive integer k such that 2(2n) - k is prime. k must always be an odd number since 2 to any power is always even. Task Find and show here, on this page, the first 10 elements of the sequence. Stretch Find and show the next sev...
#Raku
Raku
sub useful ($n) { (|$n).map: { my $p = 1 +< ( 1 +< $_ ); ^$p .first: ($p - *).is-prime } }   put useful 1..10;   put useful 11..13;
http://rosettacode.org/wiki/Ultra_useful_primes
Ultra useful primes
An ultra-useful prime is a member of the sequence where each a(n) is the smallest positive integer k such that 2(2n) - k is prime. k must always be an odd number since 2 to any power is always even. Task Find and show here, on this page, the first 10 elements of the sequence. Stretch Find and show the next sev...
#Sidef
Sidef
say(" n k") say("----------")   for n in (1..13) { var t = 2**(2**n) printf("%2d  %d\n", n, {|k| t - k -> is_prob_prime }.first) }
http://rosettacode.org/wiki/Ultra_useful_primes
Ultra useful primes
An ultra-useful prime is a member of the sequence where each a(n) is the smallest positive integer k such that 2(2n) - k is prime. k must always be an odd number since 2 to any power is always even. Task Find and show here, on this page, the first 10 elements of the sequence. Stretch Find and show the next sev...
#Wren
Wren
import "./big" for BigInt import "./fmt" for Fmt   var one = BigInt.one var two = BigInt.two   var a = Fn.new { |n| var p = (BigInt.one << (1 << n)) - one var k = 1 while (true) { if (p.isProbablePrime(5)) return k p = p - two k = k + 2 } }   System.print(" n k") System.print("...
http://rosettacode.org/wiki/Unprimeable_numbers
Unprimeable numbers
Definitions As used here, all unprimeable numbers   (positive integers)   are always expressed in base ten. ───── Definition from OEIS ─────: Unprimeable numbers are composite numbers that always remain composite when a single decimal digit of the number is changed. ───── Definition from Wiktionary   (reference...
#Delphi
Delphi
  // Unprimeable numbers. Nigel Galloway: May 4th., 2021 let rec fN i g e l=seq{yield! [0..9]|>Seq.map(fun n->n*g+e+l); if g>1 then let g=g/10 in yield! fN(i+g*(e/g)) g (e%g) i} let fG(n,g)=fN(n*(g/n)) n (g%n) 0|>Seq.exists(isPrime) let uP()=let rec fN n g=seq{yield! {n..g-1}|>Seq.map(fun g->(n,g)); yield! fN(g)(g*...
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Factor
Factor
USE: locals [let 1 :> Δ! Δ 1 + Δ! Δ . ]
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Forth
Forth
variable ∆ 1 ∆ ! 1 ∆ +! ∆ @ .
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#FreeBASIC
FreeBASIC
'FB 1.05.0 Win64   Var delta = 1 delta += 1 Print delta '' 2 Sleep
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#C.23
C#
using System;   namespace Unbias { internal class Program { private static void Main(string[] args) { // Demonstrate. for (int n = 3; n <= 6; n++) { int biasedZero = 0, biasedOne = 0, unbiasedZero = 0, unbiasedOne = 0; for (int ...
http://rosettacode.org/wiki/Untouchable_numbers
Untouchable numbers
Definitions   Untouchable numbers   are also known as   nonaliquot numbers.   An   untouchable number   is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer.   (From Wikipedia)   The   sum of all the proper divisors   is also known as   the   aliquot sum.   A...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
f = DivisorSigma[1, #] - # &; limit = 10^5; c = Not /@ PrimeQ[Range[limit]]; slimit = 15 limit; s = ConstantArray[False, slimit + 1]; untouchable = {2, 5}; Do[ val = f[i]; If[val <= slimit, s[[val]] = True ] , {i, 6, slimit} ] Do[ If[! s[[n]], If[c[[n - 1]], If[c[[n - 3]], AppendTo[untouchable, n] ...
http://rosettacode.org/wiki/Untouchable_numbers
Untouchable numbers
Definitions   Untouchable numbers   are also known as   nonaliquot numbers.   An   untouchable number   is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer.   (From Wikipedia)   The   sum of all the proper divisors   is also known as   the   aliquot sum.   A...
#Nim
Nim
import math, strutils   const Lim1 = 100_000 # Limit for untouchable numbers. Lim2 = 14 * Lim1 # Limit for computation of sum of divisors.   proc sumdiv(n: uint): uint = ## Return the sum of the strict divisors of "n". result = 1 let r = sqrt(n.float).uint let k = if (n and 1) == 0: 1u else: 2u for d ...
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#FreeBASIC
FreeBASIC
#include "dir.bi"   Sub ls(Byref filespec As String, Byval attrib As Integer) Dim As String filename = Dir(filespec, attrib) Do While Len(filename) > 0 Print filename filename = Dir() Loop End Sub   Dim As String directory = "" ' Current directory ls(directory & "*", fbDirectory) Slee...
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#Frink
Frink
for f = sort[files["."], {|a,b| lexicalCompare[a.getName[], b.getName[]]}] println[f.getName[]]
http://rosettacode.org/wiki/Vector_products
Vector products
A vector is defined as having three dimensions as being represented by an ordered collection of three numbers:   (X, Y, Z). If you imagine a graph with the   x   and   y   axis being at right angles to each other and having a third,   z   axis coming out of the page, then a triplet of numbers,   (X, Y, Z)   would repr...
#Racket
Racket
  #lang racket   (define (dot-product X Y) (for/sum ([x (in-vector X)] [y (in-vector Y)]) (* x y)))   (define (cross-product X Y) (define len (vector-length X)) (for/vector ([n len]) (define (ref V i) (vector-ref V (modulo (+ n i) len))) (- (* (ref X 1) (ref Y 2)) (* (ref X 2) (ref Y 1)))))   (define (sca...
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#TI-89_BASIC
TI-89 BASIC
Prgm InputStr "Enter a string", s Loop Prompt integer If integer ≠ 75000 Then Disp "That wasn't 75000." Else Exit EndIf EndLoop EndPrgm
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#Toka
Toka
needs readline ." Enter a string: " readline is-data the-string ." Enter a number: " readline >number [ ." Not a number!" drop 0 ] ifFalse is-data the-number   the-string type cr the-number . cr
http://rosettacode.org/wiki/Undefined_values
Undefined values
#LOLCODE
LOLCODE
HAI 1.3   I HAS A foo BTW, INISHULIZD TO NOOB DIFFRINT foo AN FAIL, O RLY? YA RLY, VISIBLE "FAIL != NOOB" OIC   I HAS A bar ITZ 42 bar, O RLY? YA RLY, VISIBLE "bar IZ DEFIND" OIC   bar R NOOB BTW, UNDEF bar bar, O RLY? YA RLY, VISIBLE "SHUD NEVAR C DIS" OIC   KTHXBYE
http://rosettacode.org/wiki/Undefined_values
Undefined values
#Lua
Lua
print( a )   local b print( b )   if b == nil then b = 5 end print( b )
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#C.23
C#
  (defvar ♥♦♣♠ "♥♦♣♠") (defun ✈ () "a plane unicode function")  
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#Common_Lisp
Common Lisp
  (defvar ♥♦♣♠ "♥♦♣♠") (defun ✈ () "a plane unicode function")  
http://rosettacode.org/wiki/Unprimeable_numbers
Unprimeable numbers
Definitions As used here, all unprimeable numbers   (positive integers)   are always expressed in base ten. ───── Definition from OEIS ─────: Unprimeable numbers are composite numbers that always remain composite when a single decimal digit of the number is changed. ───── Definition from Wiktionary   (reference...
#F.23
F#
  // Unprimeable numbers. Nigel Galloway: May 4th., 2021 let rec fN i g e l=seq{yield! [0..9]|>Seq.map(fun n->n*g+e+l); if g>1 then let g=g/10 in yield! fN(i+g*(e/g)) g (e%g) i} let fG(n,g)=fN(n*(g/n)) n (g%n) 0|>Seq.exists(isPrime) let uP()=let rec fN n g=seq{yield! {n..g-1}|>Seq.map(fun g->(n,g)); yield! fN(g)(g*...
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Frink
Frink
  Δ = 1 Δ = Δ + 1 println[Δ]  
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Go
Go
package main   import "fmt"   func main() { Δ := 1 Δ++ fmt.Println(Δ) }
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Groovy
Groovy
main = print ψ where δΔ = 1 ψ = δΔ + 1
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#Clojure
Clojure
(defn biased [n] (if (< (rand 2) (/ n)) 0 1))   (defn unbiased [n] (loop [a 0 b 0] (if (= a b) (recur (biased n) (biased n)) a)))   (for [n (range 3 7)] [n (double (/ (apply + (take 50000 (repeatedly #(biased n)))) 50000)) (double (/ (apply + (take 50000 (repeatedly #(unbiased n)))) 50000))]...
http://rosettacode.org/wiki/Untouchable_numbers
Untouchable numbers
Definitions   Untouchable numbers   are also known as   nonaliquot numbers.   An   untouchable number   is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer.   (From Wikipedia)   The   sum of all the proper divisors   is also known as   the   aliquot sum.   A...
#Pascal
Pascal
program UntouchableNumbers; program UntouchableNumbers; {$IFDEF FPC} {$MODE DELPHI} {$OPTIMIZATION ON,ALL} {$COPERATORS ON} {$CODEALIGN proc=16,loop=4} {$ELSE} {$APPTYPE CONSOLE} {$ENDIF} uses sysutils,strutils {$IFDEF WINDOWS},Windows{$ENDIF} ; const MAXPRIME = 1742537; //sqr(MaxPrime) = 3e12 LIMIT =...
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#FunL
FunL
import io.File   for f <- sort( list(File( "." ).list()).filterNot(s -> s.startsWith(".")) ) println( f )
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#Furor
Furor
  ###sysinclude dir.uh ###sysinclude stringextra.uh   ###define COLORS // delete the COLORS directive above if you do not want colored output! { „vonal” __usebigbossnamespace myself "-" 90 makestring() } { „points” __usebigbossnamespace myself "." 60 makestring() } #g argc 3 < { "." }{ 2 argv } sto mypath @mypath 'd !...
http://rosettacode.org/wiki/Vector_products
Vector products
A vector is defined as having three dimensions as being represented by an ordered collection of three numbers:   (X, Y, Z). If you imagine a graph with the   x   and   y   axis being at right angles to each other and having a third,   z   axis coming out of the page, then a triplet of numbers,   (X, Y, Z)   would repr...
#Raku
Raku
sub infix:<⋅> { [+] @^a »*« @^b }   sub infix:<⨯>([$a1, $a2, $a3], [$b1, $b2, $b3]) { [ $a2*$b3 - $a3*$b2, $a3*$b1 - $a1*$b3, $a1*$b2 - $a2*$b1 ]; }   sub scalar-triple-product { @^a ⋅ (@^b ⨯ @^c) } sub vector-triple-product { @^a ⨯ (@^b ⨯ @^c) }   my @a = <3 4 5>; my @b = <4 3 5>; my @c = <-5 -12 -13>;...
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#TUSCRIPT
TUSCRIPT
  $$ MODE TUSCRIPT LOOP ASK "Enter a string": str="" ASK "Enter an integer": int="" IF (int=='digits') THEN PRINT "int=",int," str=",str EXIT ELSE PRINT/ERROR int," is not an integer" CYCLE ENDIF ENDLOOP  
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#UNIX_Shell
UNIX Shell
#!/bin/sh   read string read integer read -p 'Enter a number: ' number echo "The number is $number"
http://rosettacode.org/wiki/Undefined_values
Undefined values
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
a -> a a + a -> 2 a ValueQ[a] -> False a = 5 -> 5 ValueQ[a] -> True
http://rosettacode.org/wiki/Undefined_values
Undefined values
#MATLAB_.2F_Octave
MATLAB / Octave
global var;
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#D
D
import std.stdio; import std.uni; // standard package for normalization, composition/decomposition, etc.. import std.utf; // standard package for decoding/encoding, etc...   void main() { // normal identifiers are allowed int a; // unicode characters are allowed for identifers int δ;   char c; // 1...
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#DWScript
DWScript
public program() { var 四十二 := "♥♦♣♠"; // UTF8 string var строка := "Привет"w; // UTF16 string   console.writeLine:строка; console.writeLine:四十二; }
http://rosettacode.org/wiki/Unprimeable_numbers
Unprimeable numbers
Definitions As used here, all unprimeable numbers   (positive integers)   are always expressed in base ten. ───── Definition from OEIS ─────: Unprimeable numbers are composite numbers that always remain composite when a single decimal digit of the number is changed. ───── Definition from Wiktionary   (reference...
#Factor
Factor
USING: assocs formatting io kernel lists lists.lazy lists.lazy.examples math math.functions math.primes math.ranges math.text.utils prettyprint sequences tools.memory.private ;   : one-offs ( n -- seq ) dup 1 digit-groups [ swapd 10^ [ * ] keep [ - ] dip 2dup [ 9 * ] [ + ] [ <range> ] tri* ] wit...
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Haskell
Haskell
main = print ψ where δΔ = 1 ψ = δΔ + 1
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#J
J
int Δ = 1; double π = 3.141592; String 你好 = "hello"; Δ++; System.out.println(Δ);
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#CoffeeScript
CoffeeScript
  biased_rand_function = (n) -> # return a function that returns 0/1 with # 1 appearing only 1/Nth of the time cap = 1/n -> if Math.random() < cap 1 else 0   unbiased_function = (f) -> -> while true [n1, n2] = [f(), f()] return n1 if n1 + n2 == 1   stats = (label, f) -> ...
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#Common_Lisp
Common Lisp
(defun biased (n) (if (zerop (random n)) 0 1))   (defun unbiased (n) (loop with x do (if (/= (setf x (biased n)) (biased n)) (return x))))   (loop for n from 3 to 6 do (let ((u (loop repeat 10000 collect (unbiased n))) (b (loop repeat 10000 collect (biased n)))) (format t "~a: unbiased ~d bia...
http://rosettacode.org/wiki/Untouchable_numbers
Untouchable numbers
Definitions   Untouchable numbers   are also known as   nonaliquot numbers.   An   untouchable number   is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer.   (From Wikipedia)   The   sum of all the proper divisors   is also known as   the   aliquot sum.   A...
#Perl
Perl
use strict; use warnings; use enum qw(False True); use ntheory qw/divisor_sum is_prime/;   sub sieve { my($n) = @_; my %s; for my $k (0 .. $n+1) { my $sum = divisor_sum($k) - $k; $s{$sum} = True if $sum <= $n+1; } %s }   my(%s,%c); my($max, $limit, $cnt) = (2000, 1e5, 0);   %s = siev...
http://rosettacode.org/wiki/Ukkonen%E2%80%99s_suffix_tree_construction
Ukkonen’s suffix tree construction
Suffix Trees are very useful in numerous string processing and computational biology problems. The task is to create a function which implements Ukkonen’s algorithm to create a useful Suffix Tree as described: Part 1 Part 2 Part 3 Part 4 Part 5 Part 6 Using Arithmetic-geometric mean/Calculate Pi generate the first 1...
#Go
Go
package main   import ( "fmt" "math/big" "time" )   var maxChar = 128   type Node struct { children []*Node suffixLink *Node start int end *int suffixIndex int }   var ( text string root *Node lastNewNode *Node ac...
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#Gambas
Gambas
Public Sub Main() Dim sDir As String[] = Dir(User.Home &/ "test").Sort()   Print sDir.Join(gb.NewLine)   End
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#Go
Go
package main   import ( "fmt" "log" "os" "sort" )   func main() { f, err := os.Open(".") if err != nil { log.Fatal(err) } files, err := f.Readdirnames(0) f.Close() if err != nil { log.Fatal(err) } sort.Strings(files) for _, n := range files { fmt.Println(n) } }
http://rosettacode.org/wiki/Vector_products
Vector products
A vector is defined as having three dimensions as being represented by an ordered collection of three numbers:   (X, Y, Z). If you imagine a graph with the   x   and   y   axis being at right angles to each other and having a third,   z   axis coming out of the page, then a triplet of numbers,   (X, Y, Z)   would repr...
#REXX
REXX
/*REXX program computes the products: dot, cross, scalar triple, and vector triple.*/ a= 3 4 5 b= 4 3 5 /*(positive numbers don't need quotes.)*/ c= "-5 -12 -13" call tellV 'vector A =', a ...
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#Ursa
Ursa
# # user input #   # in ursa, the type of data expected must be specified decl string str decl int i   out "input a string: " console set str (in string console) out "input an int: " console set i (in int console)   out "you entered " str " and " i endl console
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#VBA
VBA
Public Sub text() Debug.Print InputBox("Input a string") Debug.Print InputBox("Input the integer 75000", "Input an integer", 75000, Context = "Long") End Sub
http://rosettacode.org/wiki/Undefined_values
Undefined values
#MUMPS
MUMPS
IF $DATA(SOMEVAR)=0 DO UNDEF ; A result of 0 means the value is undefined SET LOCAL=$GET(^PATIENT(RECORDNUM,0)) ;If there isn't a defined item at that location, a null string is returned
http://rosettacode.org/wiki/Undefined_values
Undefined values
#Nim
Nim
var a {.noInit.}: array[1_000_000, int]   # For a proc, {.noInit.} means that the result is not initialized. proc p(): array[1000, int] {.noInit.} = for i in 0..999: result[i] = i
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#Elena
Elena
public program() { var 四十二 := "♥♦♣♠"; // UTF8 string var строка := "Привет"w; // UTF16 string   console.writeLine:строка; console.writeLine:四十二; }
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#Elixir
Elixir
var i int var u rune for i, u = range "voilà" { fmt.Println(i, u) }
http://rosettacode.org/wiki/Unprimeable_numbers
Unprimeable numbers
Definitions As used here, all unprimeable numbers   (positive integers)   are always expressed in base ten. ───── Definition from OEIS ─────: Unprimeable numbers are composite numbers that always remain composite when a single decimal digit of the number is changed. ───── Definition from Wiktionary   (reference...
#FreeBASIC
FreeBASIC
  Function isprime(n As Ulongint) As boolean If (n=2) Or (n=3) Then Return 1 If n Mod 2 = 0 Then Return 0 If n Mod 3 = 0 Then Return 0 Dim As Ulongint limit=Sqr(N)+1 For I As Ulongint = 6 To limit Step 6 If N Mod (i-1) = 0 Then Return 0 If N Mod (i+1) = 0 Then Return 0 Next I ...
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Java
Java
int Δ = 1; double π = 3.141592; String 你好 = "hello"; Δ++; System.out.println(Δ);
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#JavaScript
JavaScript
var ᾩ = "something"; var ĦĔĽĻŎ = "hello"; var 〱〱〱〱 = "too less"; var जावास्क्रिप्ट = "javascript"; // ok that's JavaScript in hindi var KingGeorgeⅦ = "Roman numerals.";   console.log([ᾩ, ĦĔĽĻŎ, 〱〱〱〱, जावास्क्रिप्ट, KingGeorgeⅦ])
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#jq
jq
{ "Δ": 1 } | .["Δ"]
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#D
D
import std.stdio, std.random, std.algorithm, std.range, std.functional;   enum biased = (in int n) /*nothrow*/ => uniform01 < (1.0 / n);   int unbiased(in int bias) /*nothrow*/ { int a; while ((a = bias.biased) == bias.biased) {} return a; }   void main() { enum M = 500_000; foreach (immutable n; 3 ...
http://rosettacode.org/wiki/Untouchable_numbers
Untouchable numbers
Definitions   Untouchable numbers   are also known as   nonaliquot numbers.   An   untouchable number   is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer.   (From Wikipedia)   The   sum of all the proper divisors   is also known as   the   aliquot sum.   A...
#Phix
Phix
constant limz = {1,1,8,9,18,64} -- found by experiment procedure untouchable(integer n, cols=0, tens=0) atom t0 = time(), t1 = t0+1 bool tell = n>0 n = abs(n) sequence sums = repeat(0,n+3) for i=1 to n do integer p = get_prime(i) if p>n then exit end if sums[p+1] = 1 ...
http://rosettacode.org/wiki/Ukkonen%E2%80%99s_suffix_tree_construction
Ukkonen’s suffix tree construction
Suffix Trees are very useful in numerous string processing and computational biology problems. The task is to create a function which implements Ukkonen’s algorithm to create a useful Suffix Tree as described: Part 1 Part 2 Part 3 Part 4 Part 5 Part 6 Using Arithmetic-geometric mean/Calculate Pi generate the first 1...
#Julia
Julia
const oo = typemax(Int)   """The suffix-tree's node.""" mutable struct Node children::Dict{Char, Int} start::Int ending::Int suffixlink::Int suffixindex::Int end   Node() = Node(Dict(), 0, oo, 0, -1) Node(start, ending) = Node(Dict(), start, ending, 0, -1)   """ Ukkonen Suffix-Tree """ mutable struc...
http://rosettacode.org/wiki/Ukkonen%E2%80%99s_suffix_tree_construction
Ukkonen’s suffix tree construction
Suffix Trees are very useful in numerous string processing and computational biology problems. The task is to create a function which implements Ukkonen’s algorithm to create a useful Suffix Tree as described: Part 1 Part 2 Part 3 Part 4 Part 5 Part 6 Using Arithmetic-geometric mean/Calculate Pi generate the first 1...
#Phix
Phix
-- demo/rosetta/Ukkonens_Suffix_Tree.exw with javascript_semantics integer maxChar = 'z' sequence children = {}, suffixLinks = {}, starts = {}, endIndices = {}, suffixIndices = {}, leaves = {} function new_leaf(integer v=0) leaves = append(leaves,v) return length(...
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#Haskell
Haskell
import Control.Monad import Data.List import System.Directory   dontStartWith = flip $ (/=) . head   main = do files <- getDirectoryContents "." mapM_ putStrLn $ sort $ filter (dontStartWith '.') files
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#J
J
dir '' NB. includes properties >1 1 dir '' NB. plain filename as per task
http://rosettacode.org/wiki/Vector_products
Vector products
A vector is defined as having three dimensions as being represented by an ordered collection of three numbers:   (X, Y, Z). If you imagine a graph with the   x   and   y   axis being at right angles to each other and having a third,   z   axis coming out of the page, then a triplet of numbers,   (X, Y, Z)   would repr...
#Ring
Ring
  # Project : Vector products   d = list(3) e = list(3) a = [3, 4, 5] b = [4, 3, 5] c = [-5, -12, -13]   see "a . b = " + dot(a,b) + nl cross(a,b,d) see "a x b = (" + d[1] + ", " + d[2] + ", " + d[3] + ")" + nl see "a . (b x c) = " + scalartriple(a,b,c) + nl vectortriple(a,b,c,d)   def dot(a,b) sum = 0 for n=1 ...
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#Vedit_macro_language
Vedit macro language
Get_Input(1, "Enter a string: ") #2 = Get_Num("Enter a number: ")
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#Visual_Basic_.NET
Visual Basic .NET
Dim i As Integer Console.WriteLine("Enter an Integer") i = Console.ReadLine()
http://rosettacode.org/wiki/Undefined_values
Undefined values
#OCaml
OCaml
(* There is no undefined value in OCaml, but if you really need this you can use the built-in "option" type. It is defined like this: type 'a option = None | Some of 'a *)   let inc = function Some n -> Some (n+1) | None -> failwith "Undefined argument";;   inc (Some 0);; (* - : value = Some 1 *)   inc None;; (...
http://rosettacode.org/wiki/Undefined_values
Undefined values
#Oforth
Oforth
declare X in   thread if {IsFree X} then {System.showInfo "X is unbound."} end {Wait X} {System.showInfo "Now X is determined."} end   {System.showInfo "Sleeping..."} {Delay 1000} {System.showInfo "Setting X."} X = 42
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#Erlang
Erlang
var i int var u rune for i, u = range "voilà" { fmt.Println(i, u) }
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#Go
Go
var i int var u rune for i, u = range "voilà" { fmt.Println(i, u) }
http://rosettacode.org/wiki/Unprimeable_numbers
Unprimeable numbers
Definitions As used here, all unprimeable numbers   (positive integers)   are always expressed in base ten. ───── Definition from OEIS ─────: Unprimeable numbers are composite numbers that always remain composite when a single decimal digit of the number is changed. ───── Definition from Wiktionary   (reference...
#Go
Go
package main   import ( "fmt" "strconv" )   func isPrime(n int) bool { switch { case n < 2: return false case n%2 == 0: return n == 2 case n%3 == 0: return n == 3 default: d := 5 for d*d <= n { if n%d == 0 { return false ...
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Julia
Julia
julia> Δ = 1 ; Δ += 1 ; Δ 2
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Kotlin
Kotlin
fun main(args: Array<String>) { var Δ = 1 Δ++ print(Δ) }
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Lily
Lily
var Δ = 1 Δ += 1 print(Δ.to_s())
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Lingo
Lingo
Δ = 1 Δ = Δ + 1 put Δ -- 2
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#Elena
Elena
import extensions;   extension op : IntNumber { bool randN() = randomGenerator.nextInt(self) == 0;   get bool Unbiased() { bool flip1 := self.randN(); bool flip2 := self.randN();   while (flip1 == flip2) { flip1 := self.randN(); flip2 := self.r...
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#Elixir
Elixir
defmodule Random do def randN(n) do if :rand.uniform(n) == 1, do: 1, else: 0 end def unbiased(n) do {x, y} = {randN(n), randN(n)} if x != y, do: x, else: unbiased(n) end end   IO.puts "N biased unbiased" m = 10000 for n <- 3..6 do xs = for _ <- 1..m, do: Random.randN(n) ys = for _ <- 1..m, d...
http://rosettacode.org/wiki/Untouchable_numbers
Untouchable numbers
Definitions   Untouchable numbers   are also known as   nonaliquot numbers.   An   untouchable number   is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer.   (From Wikipedia)   The   sum of all the proper divisors   is also known as   the   aliquot sum.   A...
#Raku
Raku
# 20210220 Raku programming solution   sub propdiv (\x) { my @l = 1 if x > 1; (2 .. x.sqrt.floor).map: -> \d { unless x % d { @l.push: d; my \y = x div d; @l.push: y if y != d } } @l }   sub sieve (\n) { my %s; for (0..(n+1)) -> \k { given ( [+] propdiv k ) { %s{$_} = True if $_ ≤ (n+1) } ...
http://rosettacode.org/wiki/Two_bullet_roulette
Two bullet roulette
The following is supposedly a question given to mathematics graduates seeking jobs on Wall Street: A revolver handgun has a revolving cylinder with six chambers for bullets. It is loaded with the following procedure: 1. Check the first chamber to the right of the trigger for a bullet. If a bullet is seen, the cyli...
#11l
11l
UInt32 seed = 0 F nonrandom(n)  :seed = 1664525 * :seed + 1013904223 R Int(:seed >> 16) % n   V cylinder = [0B] * 6   F rshift() V t = :cylinder[5] L(i) (4..0).step(-1)  :cylinder[i + 1] = :cylinder[i]  :cylinder[0] = t   F unload() L(i) 6  :cylinder[i] = 0B   F load() L :cylinder[0] ...
http://rosettacode.org/wiki/Ukkonen%E2%80%99s_suffix_tree_construction
Ukkonen’s suffix tree construction
Suffix Trees are very useful in numerous string processing and computational biology problems. The task is to create a function which implements Ukkonen’s algorithm to create a useful Suffix Tree as described: Part 1 Part 2 Part 3 Part 4 Part 5 Part 6 Using Arithmetic-geometric mean/Calculate Pi generate the first 1...
#Wren
Wren
import "/big" for BigRat import "/dynamic" for Struct import "/trait" for ByRef import "io" for File   var maxChar = 128   var Node = Struct.create("Node", ["children", "suffixLink", "start", "pEnd", "suffixIndex"])   var text = "" var root = null var lastNewNode = null var acti...
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#Java
Java
  package rosetta;   import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path;   public class UnixLS {   public static void main(String[] args) throws IOException { Files.list(Path.of("")).sorted().forEach(System.out::println); } }  
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#JavaScript
JavaScript
const fs = require('fs'); fs.readdir('.', (err, names) => names.sort().map( name => console.log(name) ));
http://rosettacode.org/wiki/Vector_products
Vector products
A vector is defined as having three dimensions as being represented by an ordered collection of three numbers:   (X, Y, Z). If you imagine a graph with the   x   and   y   axis being at right angles to each other and having a third,   z   axis coming out of the page, then a triplet of numbers,   (X, Y, Z)   would repr...
#Ruby
Ruby
require 'matrix'   class Vector def scalar_triple_product(b, c) self.inner_product(b.cross_product c) end   def vector_triple_product(b, c) self.cross_product(b.cross_product c) end end   a = Vector[3, 4, 5] b = Vector[4, 3, 5] c = Vector[-5, -12, -13]   puts "a dot b = #{a.inner_product b}" puts "a cro...
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#Vlang
Vlang
import os   fn main() { s := os.input('Enter string').int() if s == 75000 { println('good') } else { println('bad') } }
http://rosettacode.org/wiki/User_input/Text
User input/Text
User input/Text is part of Short Circuit's Console Program Basics selection. Task Input a string and the integer   75000   from the text console. See also: User input/Graphical
#Input_conversion_with_Error_Handling
Input conversion with Error Handling
import os import strconv   fn main() { s := strconv.atoi(os.input('Enter string')) ? if s == 75000 { println('good') } else { println('bad $s') } }
http://rosettacode.org/wiki/Undefined_values
Undefined values
#Oz
Oz
declare X in   thread if {IsFree X} then {System.showInfo "X is unbound."} end {Wait X} {System.showInfo "Now X is determined."} end   {System.showInfo "Sleeping..."} {Delay 1000} {System.showInfo "Setting X."} X = 42
http://rosettacode.org/wiki/Undefined_values
Undefined values
#PARI.2FGP
PARI/GP
v == 'v
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#Haskell
Haskell
'♥♦♣♠' ♥♦♣♠
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#J
J
'♥♦♣♠' ♥♦♣♠
http://rosettacode.org/wiki/Unicode_strings
Unicode strings
As the world gets smaller each day, internationalization becomes more and more important.   For handling multiple languages, Unicode is your best friend. It is a very capable tool, but also quite complex compared to older single- and double-byte character encodings. How well prepared is your programming language for ...
#Java
Java
--raw-input | -R :: each line of input is converted to a JSON string; --ascii-output | -a :: every non-ASCII character that would otherwise be sent to output is translated to an equivalent ASCII escape sequence; --raw-output | -r :: output strings as raw strings, ...
http://rosettacode.org/wiki/Unprimeable_numbers
Unprimeable numbers
Definitions As used here, all unprimeable numbers   (positive integers)   are always expressed in base ten. ───── Definition from OEIS ─────: Unprimeable numbers are composite numbers that always remain composite when a single decimal digit of the number is changed. ───── Definition from Wiktionary   (reference...
#Haskell
Haskell
import Control.Lens ((.~), ix, (&)) import Data.Numbers.Primes (isPrime) import Data.List (find, intercalate) import Data.Char (intToDigit) import Data.Maybe (mapMaybe) import Data.List.Split (chunksOf) import Text.Printf (printf)   isUnprimable :: Int -> Bool isUnprimable = all (not . isPrime) . swapdigits   swapdigit...
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#LiveCode
LiveCode
put 1 into Δ add 1 to Δ put Δ -- result is 2
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#LOLCODE
LOLCODE
I HAS A SRS "Δ" ITZ 1 SRS "Δ" R SUM OF SRS ":(394)" AN 1 VISIBLE SRS ":[GREEK CAPITAL LETTER DELTA]"
http://rosettacode.org/wiki/Unicode_variable_names
Unicode variable names
Task Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables. Show how to: Set a variable with a name including the 'Δ', (delta character), to 1 Increment it Print its value. Related task Case-sensitivity of identif...
#Lua
Lua
∆ = 1 ∆ = ∆ + 1 print(∆)
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#ERRE
ERRE
PROGRAM UNBIAS   FUNCTION RANDN(N) RANDN=INT(1+N*RND(1))=1 END FUNCTION   PROCEDURE UNBIASED(N->RIS) LOCAL A,B REPEAT A=RANDN(N) B=RANDN(N) UNTIL A<>B RIS=A END PROCEDURE   BEGIN PRINT(CHR$(12);) ! CLS RANDOMIZE(TIMER)   FOR N=3 TO 6 DO BIASED=0 UNBIASED=...
http://rosettacode.org/wiki/Unbias_a_random_generator
Unbias a random generator
P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} P 0 {\displaystyle P_{0}} P 0 {\displaystyle P_{0}} P 1 {\displaystyle P_{1}} Task details Use your language's random number generator to create a function/method/sub...
#Euphoria
Euphoria
function randN(integer N) return rand(N) = 1 end function   function unbiased(integer N) integer a while 1 do a = randN(N) if a != randN(N) then return a end if end while end function   constant n = 10000 integer cb, cu for b = 3 to 6 do cb = 0 cu = 0 for ...
http://rosettacode.org/wiki/Untouchable_numbers
Untouchable numbers
Definitions   Untouchable numbers   are also known as   nonaliquot numbers.   An   untouchable number   is a positive integer that cannot be expressed as the sum of all the proper divisors of any positive integer.   (From Wikipedia)   The   sum of all the proper divisors   is also known as   the   aliquot sum.   A...
#REXX
REXX
/*REXX pgm finds N untouchable numbers (numbers that can't be equal to any aliquot sum).*/ parse arg n cols tens over . /*obtain optional arguments from the CL*/ if n='' | n=="," then n=2000 /*Not specified? Then use the default.*/ if cols='' | cols=="," | cols==0 then cols= 1...
http://rosettacode.org/wiki/Two_bullet_roulette
Two bullet roulette
The following is supposedly a question given to mathematics graduates seeking jobs on Wall Street: A revolver handgun has a revolving cylinder with six chambers for bullets. It is loaded with the following procedure: 1. Check the first chamber to the right of the trigger for a bullet. If a bullet is seen, the cyli...
#AutoHotkey
AutoHotkey
methods = ( load, spin, load, spin, fire, spin, fire load, spin, load, spin, fire, fire load, load, spin, fire, spin, fire load, load, spin, fire, fire )   for i, method in StrSplit(methods, "`n", "`r"){ death := 0 main: loop 100000 { sixGun := [] for i, v in StrSplit(StrReplace(method," "), ",") if %v%() ...
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#Jsish
Jsish
# help File.glob File.glob(pattern:regexp|string|null='*', options:function|object|null=void):array Return list of files in dir with optional pattern match. With no arguments (or null) returns all files/directories in current directory. The first argument can be a pattern (either a glob or regexp) of the files to retur...
http://rosettacode.org/wiki/Unix/ls
Unix/ls
Task Write a program that will list everything in the current folder,   similar to:   the Unix utility   “ls”   [1]       or   the Windows terminal command   “DIR” The output must be sorted, but printing extended details and producing multi-column output is not required. Example output For the list of paths:...
#Julia
Julia
# v0.6.0   for e in readdir() # Current directory println(e) end   # Same for... readdir("~") # Read home directory readdir("~/documents")