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/Integer_comparison | Integer comparison |
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |... | #DCL | DCL | $ inquire a "Please provide an integer"
$ inquire b "Please provide another"
$ if a .lt. b then $ write sys$output "the first integer is less"
$ if a .eq. b then $ write sys$output "the integers have the same value"
$ if a .gt. b then $ write sys$output "the first integer is greater" |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #m4 | m4 | include(filename) |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #Maple | Maple | $include <somefile> |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | Get["myfile.m"] |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #Common_Lisp | Common Lisp |
;;
;; List of the IBAN code lengths per country.
;;
(defvar *IBAN-code-length* '((15 . ("NO"))
(16 . ("BE"))
(18 . ("DK" "FO" "FI" "GL" "NL"))
(19 . ("MK" "SI"))
(20 . ("AT" "BA" "EE" "KZ" "LT" "LU"))... |
http://rosettacode.org/wiki/Humble_numbers | Humble numbers | Humble numbers are positive integers which have no prime factors > 7.
Humble numbers are also called 7-smooth numbers, and sometimes called highly composite,
although this conflicts with another meaning of highly composite numbers.
Another way to express the above is:
humble = 2i × 3j × 5k... | #JavaScript | JavaScript | (() => {
'use strict';
// ------------------ HUMBLE NUMBERS -------------------
// humbles :: () -> [Int]
function* humbles() {
// A non-finite stream of Humble numbers.
// OEIS A002473
const hs = new Set([1]);
while (true) {
let nxt = Math.min(...hs)
... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #BQN | BQN | ⍝ Using table
Eye ← =⌜˜∘↕
•Show Eye 3
⍝ Using reshape
Eye1 ← {𝕩‿𝕩⥊1∾𝕩⥊0}
Eye1 5 |
http://rosettacode.org/wiki/Hunt_the_Wumpus | Hunt the Wumpus | This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion.
Create a simple implementation of the classic textual game Hunt The Wumpus.
The rules are:
The game is set in a cave that consists ... | #Shale | Shale |
#!/usr/local/bin/shale
// This is an implementation of the old game called Hunt the Wumpus.
//
// You can read about it here: https://en.wikipedia.org/wiki/Hunt_the_Wumpus
//
// Here's a quick summary:
//
// You are in a maze of 20 rooms, numbered 1 through 20. Each room is connected to
// 3 other rooms. There is n... |
http://rosettacode.org/wiki/Hunt_the_Wumpus | Hunt the Wumpus | This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion.
Create a simple implementation of the classic textual game Hunt The Wumpus.
The rules are:
The game is set in a cave that consists ... | #Swift | Swift |
import Foundation
//All rooms in cave
var cave: [Int:[Int]] = [
1: [2, 3, 4],
2: [1, 5, 6],
3: [1, 7, 8],
4: [1, 9, 10],
5: [2, 9, 11],
6: [2, 7, 12],
7: [3, 6, 13],
8: [3, 10, 14],
9: [4, 5, 15],
10: [4, 8, 16],
11: [5, 12, 17],
12: [6, 11, 18],
13: [7, 14, 18],
... |
http://rosettacode.org/wiki/Image_noise | Image noise | Generate a random black and white 320x240 image continuously,
showing FPS (frames per second).
A sample image
| #PL.2FI | PL/I | Image_Noise: procedure options (main); /* 3 November 2013 */
declare (start_time, end_time) float (18);
declare (frame, m, n) fixed binary;
start_time = secs();
get (m, n);
do frame = 1 to 100; /* Generate 100 frames. */
call display (m, n);
put skip data (frame);
end;
end_time = secs... |
http://rosettacode.org/wiki/Image_noise | Image noise | Generate a random black and white 320x240 image continuously,
showing FPS (frames per second).
A sample image
| #Processing | Processing | color black = color(0);
color white = color(255);
void setup(){
size(320,240);
// frameRate(300); // 60 by default
}
void draw(){
loadPixels();
for(int i=0; i<pixels.length; i++){
if(random(1)<0.5){
pixels[i] = black;
}else{
pixels[i] = white;
}
}
updatePixels();
fill(0,128);
... |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #jq | jq | def iota: ., (. + 1 | iota);
0 | iota |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #Julia | Julia | i = zero(BigInt) # or i = big(0)
while true
println(i += 1)
end |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Scheme | Scheme | +inf.0 ; positive infinity
(define (finite? x) (< -inf.0 x +inf.0))
(define (infinite? x) (not (finite? x))) |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Seed7 | Seed7 | const float: Infinity is 1.0 / 0.0; |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Sidef | Sidef | var a = 1.5/0 # Inf
say a.is_inf # true
say a.is_pos # true
var b = -1.5/0 # -Inf
say b.is_ninf # true
say b.is_neg # true
var inf = Inf
var ninf = -Inf
say (inf == -ninf) # true |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Slate | Slate | PositiveInfinity |
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #Pascal | Pascal | { for stdio }
var
s : string ;
begin
repeat
readln(s);
until s = "" ;
{ for a file }
var
f : text ;
s : string ;
begin
assignfile(f,'foo');
reset(f);
while not eof(f) do
readln(f,s);
closefile(f);
end; |
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #Perl | Perl | open FH, "< $filename" or die "can't open file: $!";
while (my $line = <FH>) {
chomp $line; # removes trailing newline
# process $line
}
close FH or die "can't close file: $!"; |
http://rosettacode.org/wiki/Josephus_problem | Josephus problem | Josephus problem is a math puzzle with a grim description:
n
{\displaystyle n}
prisoners are standing on a circle, sequentially numbered from
0
{\displaystyle 0}
to
n
−
1
{\displaystyle n-1}
.
An executioner walks along the circle, starting from prisoner
0
{\displaystyle 0}
,
removing eve... | #Ruby | Ruby | n = (ARGV[0] || 41).to_i
k = (ARGV[1] || 3).to_i
prisoners = (0...n).to_a
prisoners.rotate!(k-1).shift while prisoners.length > 1
puts prisoners.first |
http://rosettacode.org/wiki/I_before_E_except_after_C | I before E except after C | The phrase "I before E, except after C" is a
widely known mnemonic which is supposed to help when spelling English words.
Task
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt,
check if the two sub-clauses of the phrase are plausible individually:
"I before E when not pre... | #D | D | import std.file;
import std.stdio;
int main(string[] args) {
if (args.length < 2) {
stderr.writeln(args[0], " filename");
return 1;
}
int cei, cie, ie, ei;
auto file = File(args[1]);
foreach(line; file.byLine) {
auto res = eval(cast(string) line);
cei += res.cei;
... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #EGL | EGL | s string = "12345";
s = 1 + s; // Note: s + 1 is a string concatenation. |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Eiffel | Eiffel |
class
APPLICATION
create
make
feature {NONE}
make
do
io.put_string (increment_numerical_string ("7"))
io.new_line
io.put_string (increment_numerical_string ("99"))
end
increment_numerical_string (s: STRING): STRING
-- String 's' incremented by one.
do
Result := s.to_integer.plus (1).o... |
http://rosettacode.org/wiki/Integer_comparison | Integer comparison |
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |... | #Delphi | Delphi | program IntegerCompare;
{$APPTYPE CONSOLE}
var
a, b: Integer;
begin
Readln(a, b);
if a < b then Writeln(a, ' is less than ', b);
if a = b then Writeln(a, ' is equal to ', b);
if a > b then Writeln(a, ' is greater than ', b);
end. |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #MATLAB_.2F_Octave | MATLAB / Octave | % add a new directory at the end of the path
path(path,newdir);
addpath(newdir,'-end'); % same as before
% add a new directory at the beginning
addpath(newdir);
path(newdir,path); % same as before |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #Maxima | Maxima | load("c:/.../source.mac")$
/* or if source.mac is in Maxima search path (see ??file_search_maxima), simply */
load(source)$ |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #Modula-2 | Modula-2 | IMPORT InOut, NumConv, Strings; |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #D | D | import std.stdio, std.string, std.regex, std.conv, std.bigint,
std.algorithm, std.ascii;
immutable int[string] country2len;
static this() {
country2len = ["AL":28, "AD":24, "AT":20, "AZ":28, "BE":16,
"BH":22, "BA":20, "BR":29, "BG":22, "CR":21, "HR":21, "CY":28,
"CZ":24, "DK":18, "DO":28, "EE":20, ... |
http://rosettacode.org/wiki/Humble_numbers | Humble numbers | Humble numbers are positive integers which have no prime factors > 7.
Humble numbers are also called 7-smooth numbers, and sometimes called highly composite,
although this conflicts with another meaning of highly composite numbers.
Another way to express the above is:
humble = 2i × 3j × 5k... | #jq | jq |
# Input: a positive integer
# Output: true iff the input is humble
def humble:
. as $i
| if ($i < 2) then true
elif ($i % 2 == 0) then ($i / 2 | floor) | humble
elif ($i % 3 == 0) then ($i / 3 | floor) | humble
elif ($i % 5 == 0) then ($i / 5 | floor) | humble
elif ($i % 7 == 0) then ($i / 7 | f... |
http://rosettacode.org/wiki/Humble_numbers | Humble numbers | Humble numbers are positive integers which have no prime factors > 7.
Humble numbers are also called 7-smooth numbers, and sometimes called highly composite,
although this conflicts with another meaning of highly composite numbers.
Another way to express the above is:
humble = 2i × 3j × 5k... | #Julia | Julia |
function counthumbledigits(maxdigits, returnsequencelength=50)
n, count, adjustindex, maxdiff = BigInt(1), 0, BigInt(0), 0
humble, savesequence = Vector{BigInt}([1]), Vector{BigInt}()
base2, base3, base5, base7 = 1, 1, 1, 1
next2, next3, next5, next7 = BigInt(2), BigInt(3), BigInt(5), BigInt(7)
di... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #C | C |
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv) {
if (argc < 2) {
printf("usage: identitymatrix <number of rows>\n");
exit(EXIT_FAILURE);
}
int rowsize = atoi(argv[1]);
if (rowsize < 0) {
printf("Dimensions of matrix cannot be negative\n");
exit(EXIT_FAILURE)... |
http://rosettacode.org/wiki/Hunt_the_Wumpus | Hunt the Wumpus | This task has been flagged for clarification. Code on this page in its current state may be flagged incorrect once this task has been clarified. See this page's Talk page for discussion.
Create a simple implementation of the classic textual game Hunt The Wumpus.
The rules are:
The game is set in a cave that consists ... | #Wren | Wren | import "random" for Random
import "/fmt" for Fmt
import "/ioutil" for Input
import "/str" for Str
var cave = {
1: [ 2, 3, 4], 2: [ 1, 5, 6], 3: [ 1, 7, 8], 4: [ 1, 9, 10],
5: [ 2, 9, 11], 6: [ 2, 7, 12], 7: [ 3, 6, 13], 8: [ 3, 10, 14],
9: [ 4, 5, 15], 10: [ 4, 8, 16], 11: [ 5, 12... |
http://rosettacode.org/wiki/Image_noise | Image noise | Generate a random black and white 320x240 image continuously,
showing FPS (frames per second).
A sample image
| #PureBasic | PureBasic | #filter=0.2 ; Filter parameter for the FPS-calculation
#UpdateFreq=100 ; How often to update the FPS-display
OpenWindow(0,400,300,320,240,"PureBasic")
Define w=WindowWidth(0), h=WindowHeight(0)
Define x, y, T, TOld, FloatingMedium.f, cnt
InitSprite()
OpenWindowedScreen(WindowID(0),0,0,w,h,1,0,0,#PB_Screen_NoS... |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #K | K | {`0:"\n",$x+:1;x}/1 |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #Kotlin | Kotlin | import java.math.BigInteger
// version 1.0.5-2
fun main(args: Array<String>) {
// print until 2147483647
(0..Int.MAX_VALUE).forEach { println(it) }
// print forever
var n = BigInteger.ZERO
while (true) {
println(n)
n += BigInteger.ONE
}
} |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Smalltalk | Smalltalk | st> FloatD infinity
Inf
st> 1.0 / 0.0
Inf
|
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Standard_ML | Standard ML | Real.posInf |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Swift | Swift | let inf = Double.infinity
inf.isInfinite //true |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Tcl | Tcl | package require Tcl 8.5
expr {1.0 / 0} ;# ==> Inf
expr {-1.0 / 0} ;# ==> -Inf
expr {inf} ;# ==> Inf
expr {1 / 0} ;# ==> "divide by zero" error; Inf not part of range of integer division |
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #Phix | Phix | without js -- (file i/o)
procedure process_line_by_line(integer fn)
object line
while 1 do
line = gets(fn)
if atom(line) then
exit
end if
-- process the line
end while
end procedure
|
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #PHP | PHP | $fh = fopen($filename, 'r');
if ($fh) {
while (!feof($fh)) {
$line = rtrim(fgets($fh)); # removes trailing newline
# process $line
}
fclose($fh);
} |
http://rosettacode.org/wiki/Josephus_problem | Josephus problem | Josephus problem is a math puzzle with a grim description:
n
{\displaystyle n}
prisoners are standing on a circle, sequentially numbered from
0
{\displaystyle 0}
to
n
−
1
{\displaystyle n-1}
.
An executioner walks along the circle, starting from prisoner
0
{\displaystyle 0}
,
removing eve... | #Rust | Rust | const N: usize = 41;
const K: usize = 3;
const M: usize = 3;
const POSITION: usize = 5;
fn main() {
let mut prisoners: Vec<usize> = Vec::new();
let mut executed: Vec<usize> = Vec::new();
for pos in 0..N {
prisoners.push(pos);
}
let mut to_kill: usize = 0;
let mut len: usize = prisone... |
http://rosettacode.org/wiki/I_before_E_except_after_C | I before E except after C | The phrase "I before E, except after C" is a
widely known mnemonic which is supposed to help when spelling English words.
Task
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt,
check if the two sub-clauses of the phrase are plausible individually:
"I before E when not pre... | #Delphi | Delphi |
program I_before_E_except_after_C;
uses
System.SysUtils, System.IOUtils;
function IsOppPlausibleWord(w: string): Boolean;
begin
if ((not w.Contains('c')) and (w.Contains('ei'))) then
exit(True);
if (w.Contains('cie')) then
exit(True);
exit(false);
end;
function IsPlausibleWord(w: string): Bo... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Elena | Elena | import extensions;
public program()
{
var s := "12345";
s := (s.toInt() + 1).toString();
console.printLine(s)
} |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Elixir | Elixir | increment1 = fn n -> to_string(String.to_integer(n) + 1) end
# Or piped
increment2 = fn n -> n |> String.to_integer |> +1 |> to_string end
increment1.("1")
increment2.("100") |
http://rosettacode.org/wiki/Integer_comparison | Integer comparison |
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |... | #Draco | Draco | proc nonrec main() void:
int a, b;
write("Please enter two integers: ");
read(a, b);
if a<b then writeln(a, " < ", b)
elif a=b then writeln(a, " = ", b)
elif a>b then writeln(a, " > ", b)
fi
corp |
http://rosettacode.org/wiki/Integer_comparison | Integer comparison |
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |... | #Dyalect | Dyalect | func compare(a, b) {
if a < b {
"A is less than B"
} else if a > b {
"A is more than B"
} else {
"A equals B"
}
} |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #Modula-3 | Modula-3 | IMPORT IO, Text AS Str;
FROM Str IMPORT T |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #Nanoquery | Nanoquery | import "filename.nq" |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #Nemerle | Nemerle | using System.Console; |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #DBL | DBL | ;
; Validate IBAN for DBL version 4 by Dario B.
;
; Compile with "dbl -r" to reinitialize all data each time
; the module (main or subroutine) is entered.
;
RECORD
J, D5
ISVALID, D1
IBAN, A35,'GB82 WEST 1234 5698 7654 32'
, A35,'GB82 TEST 1234 5698 7654 32'
, A35,'GR16... |
http://rosettacode.org/wiki/Humble_numbers | Humble numbers | Humble numbers are positive integers which have no prime factors > 7.
Humble numbers are also called 7-smooth numbers, and sometimes called highly composite,
although this conflicts with another meaning of highly composite numbers.
Another way to express the above is:
humble = 2i × 3j × 5k... | #Kotlin | Kotlin | fun isHumble(i: Int): Boolean {
if (i <= 1) return true
if (i % 2 == 0) return isHumble(i / 2)
if (i % 3 == 0) return isHumble(i / 3)
if (i % 5 == 0) return isHumble(i / 5)
if (i % 7 == 0) return isHumble(i / 7)
return false
}
fun main() {
val limit: Int = Short.MAX_VALUE.toInt()
val h... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #C.23 | C# |
using System;
using System.Linq;
namespace IdentityMatrix
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Requires exactly one argument");
return;
}
int n;
... |
http://rosettacode.org/wiki/Image_noise | Image noise | Generate a random black and white 320x240 image continuously,
showing FPS (frames per second).
A sample image
| #Python | Python | import time
import random
import Tkinter
import Image, ImageTk # PIL libray
class App(object):
def __init__(self, size, root):
self.root = root
self.root.title("Image Noise Test")
self.img = Image.new("RGB", size)
self.label = Tkinter.Label(root)
self.label.pack()
... |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #Lambdatalk | Lambdatalk |
{def infinite_set
{lambda {:i}
{if true // will never change
then :i {infinite_set {long_add :i 1}} // extends {+ :i 1}
else You have reached infinity! }}} // probably never.
-> infinite_set
{infinite_set 0}
-> 0 1 2 3 ... forever
|
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #Lang5 | Lang5 | 0 do dup . 1 + loop |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #TI-89_BASIC | TI-89 BASIC | ∞ |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #TorqueScript | TorqueScript | function infinity()
{
return 1/0;
} |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Trith | Trith |
: inf 1.0 0.0 / ;
: -inf inf neg ;
: inf? abs inf = ;
|
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Ursa | Ursa | decl double d
set d Infinity |
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #Picat | Picat | main =>
Reader = open("file.txt"),
while(not at_end_of_stream(Reader))
L = read_line(Reader),
println(L)
end,
close(Reader). |
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #PicoLisp | PicoLisp | (in "file.txt"
(make
(until (eof)
(link (line)) ) ) ) |
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #PL.2FI | PL/I | declare line character (200) varying;
open file (in) title ('/TEXT.DAT,type(text),recsize(200)' );
on endfile (in) stop;
do forever;
get file(in) edit (line) (L);
put skip list (line);
end; |
http://rosettacode.org/wiki/Josephus_problem | Josephus problem | Josephus problem is a math puzzle with a grim description:
n
{\displaystyle n}
prisoners are standing on a circle, sequentially numbered from
0
{\displaystyle 0}
to
n
−
1
{\displaystyle n-1}
.
An executioner walks along the circle, starting from prisoner
0
{\displaystyle 0}
,
removing eve... | #Scala | Scala | def executed( prisonerCount:Int, step:Int ) = {
val prisoners = ((0 until prisonerCount) map (_.toString)).toList
def behead( dead:Seq[String], alive:Seq[String] )(countOff:Int) : (Seq[String], Seq[String]) = {
val group = if( alive.size < countOff ) countOff - alive.size else countOff
(dead ++ alive.... |
http://rosettacode.org/wiki/I_before_E_except_after_C | I before E except after C | The phrase "I before E, except after C" is a
widely known mnemonic which is supposed to help when spelling English words.
Task
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt,
check if the two sub-clauses of the phrase are plausible individually:
"I before E when not pre... | #Draco | Draco | \util.g
/* variables to hold totals for each possibility */
word cie, xie, cei, xei;
/* classify a word and add it to the proper total */
proc nonrec classify(*char w) void:
if CharsIndex(w, "ie") /= -1 then
if CharsIndex(w, "cie") /= -1
then cie := cie + 1
else xie := xie + 1
... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Emacs_Lisp | Emacs Lisp | (1+ (string-to-number "12345")) |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Erlang | Erlang | integer_to_list(list_to_integer("1336")+1). |
http://rosettacode.org/wiki/Integer_comparison | Integer comparison |
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |... | #E | E | def compare(a :int, b :int) {
println(if (a < b) { `$a < $b` } \
else if (a <=> b) { `$a = $b` } \
else if (a > b) { `$a > $b` } \
else { `You're calling that an integer?` })
} |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #NewLISP | NewLISP | ;; local file
(load "file.lsp")
;; URLs (both http:// and file:// URLs are supported)
(load "http://www.newlisp.org/code/modules/ftp.lsp") |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #Elixir | Elixir | defmodule IBAN do
@len %{ AL: 28, AD: 24, AT: 20, AZ: 28, BE: 16, BH: 22, BA: 20, BR: 29,
BG: 22, CR: 21, HR: 21, CY: 28, CZ: 24, DK: 18, DO: 28, EE: 20,
FO: 18, FI: 18, FR: 27, GE: 22, DE: 22, GI: 23, GR: 27, GL: 18,
GT: 28, HU: 28, IS: 26, IE: 22, IL: 23, IT: 27, KZ: 20, KW: 30,
... |
http://rosettacode.org/wiki/Humble_numbers | Humble numbers | Humble numbers are positive integers which have no prime factors > 7.
Humble numbers are also called 7-smooth numbers, and sometimes called highly composite,
although this conflicts with another meaning of highly composite numbers.
Another way to express the above is:
humble = 2i × 3j × 5k... | #Lua | Lua | function isHumble(n)
local n2 = math.floor(n)
if n2 <= 1 then
return true
end
if n2 % 2 == 0 then
return isHumble(n2 / 2)
end
if n2 % 3 == 0 then
return isHumble(n2 / 3)
end
if n2 % 5 == 0 then
return isHumble(n2 / 5)
end
if n2 % 7 == 0 then
... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #C.2B.2B | C++ | template<class T>
class matrix
{
public:
matrix( unsigned int nSize ) :
m_oData(nSize * nSize, 0), m_nSize(nSize) {}
inline T& operator()(unsigned int x, unsigned int y)
{
return m_oData[x+m_nSize*y];
}
void identity()
{
int nCount = 0;
int nStr... |
http://rosettacode.org/wiki/Image_noise | Image noise | Generate a random black and white 320x240 image continuously,
showing FPS (frames per second).
A sample image
| #Racket | Racket |
#lang racket
(require 2htdp/image 2htdp/universe)
(define black (color 0 0 0 255))
(define white (color 255 255 255 255))
(define-struct world (last fps))
(define (noise w h)
(color-list->bitmap
(for*/list ([x (in-range w)] [y (in-range h)])
(if (zero? (random 2)) black white))
w h))
(defin... |
http://rosettacode.org/wiki/Image_noise | Image noise | Generate a random black and white 320x240 image continuously,
showing FPS (frames per second).
A sample image
| #Raku | Raku | use NativeCall;
use SDL2::Raw;
my int ($w, $h) = 320, 240;
SDL_Init(VIDEO);
my SDL_Window $window = SDL_CreateWindow(
"White Noise - Raku",
SDL_WINDOWPOS_CENTERED_MASK, SDL_WINDOWPOS_CENTERED_MASK,
$w, $h,
RESIZABLE
);
my SDL_Renderer $renderer = SDL_CreateRenderer( $window, -1, ACCELERATED +| T... |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #Lasso | Lasso | local(number = 1)
while(#number > 0) => {^
#number++
' '
//#number > 100 ? #number = -2 // uncomment this row if you want to halt the run after proving concept
^} |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #Liberty_BASIC | Liberty BASIC | while 1
i=i+1
locate 1,1
print i
scan
wend
|
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Ursala | Ursala | #import flo
infinity = inf! |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Visual_Basic | Visual Basic | Option Explicit
Private Declare Sub GetMem8 Lib "msvbvm60.dll" _
(ByVal SrcAddr As Long, ByVal TarAddr As Long)
Sub Main()
Dim PlusInfinity As Double
Dim MinusInfinity As Double
Dim IndefiniteNumber As Double
On Error Resume Next
PlusInfinity = 1 / 0
MinusInfinity = -1 / 0
IndefiniteNumber = 0 / 0... |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Vlang | Vlang | import math
fn main() {
mut x := 1.5 // type of x determined by literal
// that this compiles demonstrates that PosInf returns same type as x,
// the type specified by the task.
x = math.inf(1)
println('$x ${math.is_inf(x, 1)}') // demonstrate result
} |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Wren | Wren | var x = 1.5
var y = x / 0
System.print("x = %(x)")
System.print("y = %(y)")
System.print("'x' is infinite? %(x.isInfinity)")
System.print("'y' is infinite? %(y.isInfinity)") |
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #PowerShell | PowerShell | Get-Content c:\file.txt |
ForEach-Object {
$_
} |
http://rosettacode.org/wiki/Input_loop | Input loop | Input loop is part of Short Circuit's Console Program Basics selection.
Task
Read from a text stream either word-by-word or line-by-line until the stream runs out of data.
The stream will have an unknown amount of data on it.
| #PureBasic | PureBasic | If OpenConsole()
; file based line wise
If ReadFile(0, "Text.txt")
While Eof(0) = 0
Debug ReadString(0) ; each line until eof
Wend
CloseFile(0)
EndIf
; file based byte wise
If ReadFile(1, "Text.bin")
While Eof(1) = 0
Debug ReadByte(1) ... |
http://rosettacode.org/wiki/Josephus_problem | Josephus problem | Josephus problem is a math puzzle with a grim description:
n
{\displaystyle n}
prisoners are standing on a circle, sequentially numbered from
0
{\displaystyle 0}
to
n
−
1
{\displaystyle n-1}
.
An executioner walks along the circle, starting from prisoner
0
{\displaystyle 0}
,
removing eve... | #Seed7 | Seed7 | $ include "seed7_05.s7i";
const func array integer: executeAllButM (in integer: n, in integer: k, in integer: m) is func
result
var array integer: prisoners is [0 .. -1] times 0;
local
var integer: killIdx is 0;
var integer: prisonerNum is 0;
begin
for prisonerNum range 0 to pred(n) do
pri... |
http://rosettacode.org/wiki/I_before_E_except_after_C | I before E except after C | The phrase "I before E, except after C" is a
widely known mnemonic which is supposed to help when spelling English words.
Task
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt,
check if the two sub-clauses of the phrase are plausible individually:
"I before E when not pre... | #Elixir | Elixir | defmodule RC do
def task(path) do
plausibility_ratio = 2
rules = [ {"I before E when not preceded by C:", "ie", "ei"},
{"E before I when preceded by C:", "cei", "cie"} ]
regex = ~r/ie|ei|cie|cei/
counter = File.read!(path) |> countup(regex)
Enum.all?(rules, fn {str, x, y} ->
nx... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #ERRE | ERRE |
....................
s$="12345"
s$=STR$(VAL(s$)+1)
....................
|
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Euphoria | Euphoria | include get.e
function val(sequence s)
sequence x
x = value(s)
return x[2]
end function
sequence s
s = "12345"
s = sprintf("%d",{val(s)+1}) |
http://rosettacode.org/wiki/Integer_comparison | Integer comparison |
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |... | #EasyLang | EasyLang | a = number input
b = number input
if a < b
print "less"
.
if a = b
print "equal"
.
if a > b
print "greater"
. |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #Nim | Nim | import someModule
import strutils except parseInt
import strutils as su, sequtils as qu # su.x works
import pure/os, "pure/times" # still strutils.x |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #OASYS_Assembler | OASYS Assembler | #use "some_file.ml" |
http://rosettacode.org/wiki/Include_a_file | Include a file | Task
Demonstrate the language's ability to include source code from other files.
See Also
Compiler/Simple file inclusion pre processor
| #OCaml | OCaml | #use "some_file.ml" |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #F.23 | F# | open System
open System.Text.RegularExpressions
// A little utility to thread a negative test result (Option.None) through a
// pipeline of tests
let inline (|~>) valOption proc =
match valOption with
| Some(value) -> proc value
| None -> None
[<EntryPoint>]
let main argv =
let iban = if argv.Length... |
http://rosettacode.org/wiki/Humble_numbers | Humble numbers | Humble numbers are positive integers which have no prime factors > 7.
Humble numbers are also called 7-smooth numbers, and sometimes called highly composite,
although this conflicts with another meaning of highly composite numbers.
Another way to express the above is:
humble = 2i × 3j × 5k... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | HumbleGenerator[max_] :=
Sort[Flatten@ParallelTable[
2^i 3^j 5^k 7^m, {i, 0, Log[2, max]}, {j, 0, Log[3, max/2^i]}, {k,
0, Log[5, max/(2^i 3^j)]}, {m, 0, Log[7, max/(2^i 3^j 5^k)]}]]
{"First 50 Humble Numbers:",
HumbleGenerator[120],
"\nDigits\[Rule]Count",
Rule @@@ Tally[IntegerLength /@ Drop[Humbl... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #Clio | Clio | fn identity-matrix n:
[0:n] -> * fn i:
[0:n] -> * if = i: 1
else: 0
5 -> identity-matrix -> * print |
http://rosettacode.org/wiki/Image_noise | Image noise | Generate a random black and white 320x240 image continuously,
showing FPS (frames per second).
A sample image
| #REXX | REXX | /*REXX program times (elapsed) the generation of 100 frames of random black&white image.*/
parse arg sw sd im . /*obtain optional args from the C.L. */
if sw=='' | sw=="," then sw=320 /*SW specified? No, then use default.*/
if sd=='' | sd=="," then sd=240 ... |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #Limbo | Limbo | implement CountToInfinity;
include "sys.m"; sys: Sys;
include "draw.m";
include "ipints.m"; ipints: IPints;
IPint: import ipints;
CountToInfinity: module {
init: fn(nil: ref Draw->Context, nil: list of string);
};
init(nil: ref Draw->Context, nil: list of string)
{
sys = load Sys Sys->PATH;
ipints = load IPin... |
http://rosettacode.org/wiki/Integer_sequence | Integer sequence | Task
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit), in sequence (i.e. 1, 2, 3, 4, etc) if given enough time.
An example may not be able to reach arbitrarily-large numbers based on implementations limits. For example, if integer... | #Lingo | Lingo | i = 1
repeat while i>0
put i
i = i+1
end repeat |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #XPL0 | XPL0 | int A;
real X;
[Format(0, 15); \output in scientific notation
A:= addr X; \get address of (pointer to) X
A(0):= $FFFF_FFFF; \stuff in largest possible value
A(1):= $7FEF_FFFF;
RlOut(0, X); \display it
] |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Yabasic | Yabasic | infinity = 1e300*1e300
if str$(infinity) = "inf" print "Infinity" |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #Zig | Zig | const std = @import("std");
const debug = std.debug;
const math = std.math;
test "infinity" {
const infinite_f16 = math.inf(f16);
const infinite_f32 = math.inf(f32);
const infinite_f64 = math.inf(f64);
const infinite_f128 = math.inf(f128);
// Any other types besides these four floating types a... |
http://rosettacode.org/wiki/Infinity | Infinity | Task
Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible po... | #zkl | zkl | 1.5/0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.