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_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... | #Raku | Raku | .say for 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... | #Raven | Raven | 1 as $i
repeat TRUE while
$i "%d\n" print $i 1000 + as $i |
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... | #Red | Red | Red ["Integer sequence"]
i: 1
forever [
print i
i: i + 1
] |
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... | #Perl | Perl | #!/usr/bin/perl
use warnings;
use strict;
sub result {
my ($support, $against) = @_;
my $ratio = sprintf '%.2f', $support / $against;
my $result = $ratio >= 2;
print "$support / $against = $ratio. ", 'NOT ' x !$result, "PLAUSIBLE\n";
return $result;
}
my @keys = qw(ei cei ie cie);
my %count;
... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #LIL | LIL | ##
Increment a numerical string, in LIL
##
set a "41"
inc a
print $a |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Lingo | Lingo | put integer("123")+1
-- 124 |
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 |... | #HicEst | HicEst | DLG(NameEdit=a, NameEdit=b, Button='OK')
IF (a < b) THEN
WRITE(Messagebox) a, ' is less than ', b
ELSEIF(a == b) THEN
WRITE(Messagebox) a, ' is equal to ', b
ELSEIF(a > b) THEN
WRITE(Messagebox) a, ' is greater than ', b
ENDIF |
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... | #MATLAB | MATLAB | function valid = validateIBAN(iban)
% Determine if International Bank Account Number is valid IAW ISO 13616
% iban - string containing account number
if length(iban) < 5
valid = false;
else
iban(iban == ' ') = ''; % Remove spaces
iban = lower([iban(5:end) iban(1:4)])+... |
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
⋮
⋮
⋮
⋱
... | #F.C5.8Drmul.C3.A6 | Fōrmulæ |
include "NSLog.incl"
local fn IdentityMatrix( n as NSInteger ) as CFStringRef
NSInteger i, j
CFMutableArrayRef tempArr = fn MutableArrayWithCapacity( n )
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
for i = 0 to n - 1
MutableArrayRemoveAllObjects( tempArr )
for j = 0 to n - 1
MutableArrayInsertOb... |
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... | #Retro | Retro | #0 [ [ n:put spa ] sip n:inc dup n:-zero? ] while drop |
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... | #REXX | REXX | /*count all the protons, electrons, & whatnot in the universe, and then */
/*keep counting. According to some pundits in-the-know, one version of */
/*the big-bang theory is that the universe will collapse back to where */
/*it started, and this computer program will be still counting. */
/*┌─────────────────... |
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... | #Phix | Phix | -- demo\rosetta\IbeforeE.exw
with javascript_semantics
procedure show_plausibility(string msg, integer w, wo)
string no = iff(w<2*wo?" not":"")
printf(1, "%s (pro: %3d, anti: %3d) is%s plausible\n",{msg,w,wo,no})
end procedure
string text = join(unix_dict())
-- Note: my unixdict.txt begins with "10th" and ends... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #LiveCode | LiveCode | put "0" & "1234" into myString -- I think this will result in an internal string representation
add 1 to myString -- automatically converts to a number
put "The number is:" && myString
-- outputs "The number is: 1235" |
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 |... | #HolyC | HolyC | I64 *a, *b;
a = Str2I64(GetStr("Enter your first number: "));
b = Str2I64(GetStr("Enter your second number: "));
if (a < b)
Print("%d is less than %d\n", a, b);
if (a == b)
Print("%d is equal to %d\n", a, b);
if (a > b)
Print("%d is greater than %d\n", a, b); |
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... | #NewLISP | NewLISP |
(setq *iban-code-length* '((15 ("NO"))
(16 ("BE"))
(18 ("DK" "FO" "FI" "GL" "NL"))
(19 ("MK" "SI"))
(20 ("AT" "BA" "EE" "KZ" "LT" "LU"))
(21 ("CR" "HR" "LV" "LI" "CH... |
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
⋮
⋮
⋮
⋱
... | #FutureBasic | FutureBasic |
include "NSLog.incl"
local fn IdentityMatrix( n as NSInteger ) as CFStringRef
NSInteger i, j
CFMutableArrayRef tempArr = fn MutableArrayWithCapacity( n )
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
for i = 0 to n - 1
MutableArrayRemoveAllObjects( tempArr )
for j = 0 to n - 1
MutableArrayInsertOb... |
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... | #Ring | Ring |
size = 10
for n = 1 to size
see n + nl
next
see nl
for n in [1:size]
see n + nl
next
see nl
i = n
while n <= size
see n + nl
n = n + 1
end
|
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... | #Ruby | Ruby | 1.step{|n| puts n} |
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... | #Picat | Picat | main =>
Words = read_file_lines("unixdict.txt"),
IEWords = [Word : Word in Words, find(Word,"ie",_,_)],
EIWords = [Word : Word in Words, find(Word,"ei",_,_)],
% cie vs not cie
[CIE_len, CIE_not_len] = partition_len(IEWords,"cie"),
println([cie=CIE_len,cie_not=CIE_not_len]),
% cei vs not cei
[CEI_... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Logo | Logo | show "123 + 1 ; 124
show word? ("123 + 1) ; true |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Logtalk | Logtalk | number_chars(Number, "123"), Number2 is Number+1, number_chars(Number2, String2) |
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 |... | #Hy | Hy | (def a (int (input "Enter value of a: ")))
(def b (int (input "Enter value of b: ")))
(print (cond [(< a b) "a is less than b"]
[(> a b) "a is greater than b"]
[(= a b) "a is equal to b"])) |
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... | #Nim | Nim | import tables, strutils, re, bigints
let countryLen = toTable({
"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": ... |
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
⋮
⋮
⋮
⋱
... | #GAP | GAP | # Built-in
IdentityMat(3);
# One can also specify the base ring
IdentityMat(3, Integers mod 10); |
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... | #Run_BASIC | Run BASIC | while 1
i = i + 1
print i
wend |
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... | #Rust | Rust | fn main() {
for i in 0.. {
println!("{}", i);
}
} |
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... | #PicoLisp | PicoLisp | (de ibEeaC (File . Prg)
(let
(Cie (let N 0 (in File (while (from "cie") (run Prg))))
Nie (let N 0 (in File (while (from "ie") (run Prg))))
Cei (let N 0 (in File (while (from "cei") (run Prg))))
Nei (let N 0 (in File (while (from "ei") (run Prg)))) )
(prinl "cie: " Cie)
(p... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #LOLCODE | LOLCODE | HAI 1.3
I HAS A foo ITZ "1234"
foo R SUM OF foo AN 1
VISIBLE foo BTW, prints 1235
KTHXBYE |
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 |... | #i | i | software {
a = number(read(' '))
b = number(read())
if a < b
print(a, " is less than ", b)
end
if a = b
print(a, " is equal to ", b)
end
if a > b
print(a, " is greater than ", b)
end
} |
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... | #Oberon-2 | Oberon-2 |
MODULE IBAN;
IMPORT
Out,
Err,
ADT:Dictionary,
Object:Boxed,
Object:BigInt,
Object,
Strings,
IntStr;
TYPE
IBANLen = Boxed.LongInt;
VAR
nations: Dictionary.Dictionary(STRING,IBANLen);
PROCEDURE Check*(iban: ARRAY OF CHAR): BOOLEAN;
VAR
country,ibanStr: Object.String;
nLetter: ARRAY 3 O... |
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
⋮
⋮
⋮
⋱
... | #Go | Go | package main
import (
"fmt"
"gonum.org/v1/gonum/mat"
)
func eye(n int) *mat.Dense {
m := mat.NewDense(n, n, nil)
for i := 0; i < n; i++ {
m.Set(i, i, 1)
}
return m
}
func main() {
fmt.Println(mat.Formatted(eye(3)))
} |
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... | #Salmon | Salmon | iterate (i; [0...+oo])
i!; |
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... | #Scala | Scala | Stream from 1 foreach println |
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... | #PL.2FI | PL/I | iBeforeE: procedure options(main);
declare dict file;
open file(dict) title('unixdict.txt');
on endfile(dict) go to report;
declare (cie, xie, cei, xei) fixed;
declare word char(32) varying;
cie = 0;
xie = 0;
cei = 0;
xei = 0;
do while('1'b);
get file(dict) list(word);
... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #LSL | LSL | default {
state_entry() {
llListen(PUBLIC_CHANNEL, "", llGetOwner(), "");
llOwnerSay("Say a Number and I'll Increment it.");
}
listen(integer iChannel, string sName, key kId, string sMessage) {
llOwnerSay("You said '"+sMessage+"' + 1 = "+(string)(((integer)sMessage)+1));
}
} |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Lua | Lua | > -- A STRING THAT CAN BE IMPLICITLY CONVERTED TO A NUMBER
> s = "1234"
> s+1 -- implicitly convert to number, add 1, remain a number
1235
> type(s+1)
number
> (s+1)..'' -- implicitly convert to number, add 1, implicitly convert back to string
1235
> type((s+1)..'')
string
> tostring(s+1) -- implicitly convert to numbe... |
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 |... | #Icon_and_Unicon | Icon and Unicon | procedure main()
until integer(a) do {
writes("Enter the first integer a := ")
write(a := read())
}
until integer(b) do {
writes("Enter the second integer b := ")
write(b := read())
}
writes("Then ")
write(a," < ", a < b)
write(a," = ", a = b)
write(a," > ", a > b)
end |
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... | #OCaml | OCaml |
#load "str.cma"
#load "nums.cma" (* for module Big_int *)
(* Countries and length of their IBAN. *)
(* Taken from https://en.wikipedia.org/wiki/International_Bank_Account_Number#IBAN_formats_by_country *)
let countries = [
("AL", 28); ("AD", 24); ("AT", 20); ("AZ", 28); ("BH", 22); ("BE", 16);
("BA", 20); ("... |
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
⋮
⋮
⋮
⋱
... | #Groovy | Groovy | def makeIdentityMatrix = { n ->
(0..<n).collect { i -> (0..<n).collect { j -> (i == j) ? 1 : 0 } }
} |
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... | #Scheme | Scheme |
(let loop ((i 1))
(display i) (newline)
(loop (+ 1 i)))
|
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... | #Seed7 | Seed7 | $ include "seed7_05.s7i";
const proc: main is func
local
var integer: number is 0;
begin
repeat
incr(number);
writeln(number);
until number = 2147483647;
end func; |
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... | #PowerShell | PowerShell | $Web = New-Object -TypeName Net.Webclient
$Words = $web.DownloadString('http://wiki.puzzlers.org/pub/wordlists/unixdict.txt')
$IE = $EI = $CIE = $CEI = @()
$Clause1 = $Clause2 = $MainClause = $false
foreach ($Word in $Words.split())
{
switch ($Word)
{
{($_ -like '*ie*') -and ($_ -notlike '*cie*')}... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #M2000_Interpreter | M2000 Interpreter |
Module CheckIt {
s$ = "12345"
s$ = STR$(VAL(s$) + 1,"")
Print S$
\\ using , for decimal point like in Locale 1032 for Greece
s$ = "123,45"
\\ we get value in Locale 1032
S$=Str$(VAL(s$,",") + 1, 1032)
}
CheckIt
|
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #M4 | M4 | define(`V',`123')dnl
define(`VN',`-123')dnl
eval(V+1)
eval(VN+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 |... | #J | J | compare=: < , = , >
cti=: dyad define
select =. ;@#
English =. ' is less than ';' is equal to ';' is greater than '
x (":@[, (compare select English"_), ":@]) y
) |
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 |... | #Java | Java | import java.io.*;
public class compInt {
public static void main(String[] args) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int nbr1 = Integer.parseInt(in.readLine());
int nbr2 = Integer.parseInt(in.readLine());
if(nbr1<nb... |
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #C.23 | C# |
using System;
using System.Net;
class Program
{
class MyWebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
request.ClientCertificates.Add(new X509Certificate());
... |
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... | #Perl | Perl | #!/usr/bin/perl
use strict ;
use warnings ;
use Math::BigInt ;
my %countrycodelengths = ( "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,... |
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
⋮
⋮
⋮
⋱
... | #Haskell | Haskell | matI n = [ [fromEnum $ i == j | i <- [1..n]] | j <- [1..n]] |
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... | #Sidef | Sidef | {|i| say i } * Math.inf; |
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... | #Smalltalk | Smalltalk | i := 0.
[
Stdout print:i; cr.
i := i + 1
] loop |
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... | #PureBasic | PureBasic | If ReadFile(1,GetPathPart(ProgramFilename())+"wordlist(en).txt")
While Not Eof(1)
wl$+ReadString(1)+";"
Wend
CloseFile(1)
EndIf
OpenConsole()
PrintN("Number of words in [wordlist(en).txt]: "+CountString(wl$,";"))
cei.i=CountString(wl$,"cei") : PrintN("Instances of [cei] : "+Str(cei))
cie.i... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Maple | Maple | s := "12345";
s := convert(parse(s)+1, string); |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | FromDigits["1234"] + 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 |... | #JavaScript | JavaScript |
// Using type coercion
function compare(a, b) {
if (a==b) print(a + " equals " + b);
if (a < b) print(a + " is less than " + b);
if (a > b) print(a + " is greater than " + b);
}
// Without using type coercion and using standards
// Written for browsers
// assumption of a and b are both integers if typeof test... |
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #Go | Go | package main
import (
"crypto/tls"
"io/ioutil"
"log"
"net/http"
)
func main() {
// load key pair
cert, err := tls.LoadX509KeyPair(
"./client.local.tld/client.local.tld.crt",
"./client.local.tld/client.local.tld.key",
)
if err != nil {
log.Fatal("Error while loading x509 key pair", err)
}
// Cr... |
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #Julia | Julia | using HTTP, MbedTLS
conf = MbedTLS.SSLConfig(true, log_secrets="/utl/secret_key_log.log")
resp = HTTP.get("https://httpbin.org/ip", sslconfig=conf)
println(resp)
|
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... | #Phix | Phix | --
-- demo\rosetta\IBAN.exw
-- =====================
--
constant nations = {{"AD",24}, -- Andorra
-- (full list in distro)
{"CH",21}, -- Switzerland
{"GB",22}, -- United Kingdom
{"SA",24}, -- Saudi Arabia
{"XK",20}}... |
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
⋮
⋮
⋮
⋱
... | #Icon_and_Unicon | Icon and Unicon | link matrix
procedure main(argv)
if not (integer(argv[1]) > 0) then stop("Argument must be a positive integer.")
matrix1 := identity_matrix(argv[1], argv[1])
write_matrix(&output,matrix1)
end
|
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... | #SSEM | SSEM | 01000000000000010000000000000000 0. Sub. 2 acc -= -1
01000000000000000000000000000000 1. 2 to CI goto -1 + 1
11111111111111111111111111111111 2. -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... | #Standard_ML | Standard ML | let
fun printInts(n) =
(
print(Int.toString(n) ^ "\n");
printInts(n+1)
)
in
printInts(1)
end; |
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... | #Python | Python | import urllib.request
import re
PLAUSIBILITY_RATIO = 2
def plausibility_check(comment, x, y):
print('\n Checking plausibility of: %s' % comment)
if x > PLAUSIBILITY_RATIO * y:
print(' PLAUSIBLE. As we have counts of %i vs %i, a ratio of %4.1f times'
% (x, y, x / y))
else:
... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #MATLAB | MATLAB | function numStr = incrementNumStr(numStr)
numStr = num2str(str2double(numStr) + 1);
end |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #MAXScript | MAXScript | str = "12345"
str = ((str as integer) + 1) as string |
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 |... | #Joy | Joy | #!/usr/local/bin/joy.exe
DEFINE
prompt == "Please enter a number and <Enter>: " putchars;
newline == '\n putch;
putln == put newline.
stdin # F
prompt fgets # S F
10 strtol # A F
swap # F A
dupd # F A A
prompt fgets # S F A A
10 strtol # B F A A
popd # B A A
dup # B B A A
rollup # B A B A
[<] [swap put "is l... |
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #Kotlin | Kotlin | // version 1.2.0
import java.security.KeyStore
import javax.net.ssl.KeyManagerFactory
import javax.net.ssl.SSLContext
import javax.net.ssl.HttpsURLConnection
import java.net.URL
import java.io.FileInputStream
import java.io.InputStreamReader
import java.io.BufferedReader
fun getSSLContext(p12Path: String, password:... |
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #Lasso | Lasso | local(sslcert = file('myCert.pem'))
local(x = curl('https://sourceforge.net'))
#x->set(CURLOPT_SSLCERT, #sslcert->readstring)
#sslcert->close
#x->result->asString |
http://rosettacode.org/wiki/HTTPS/Authenticated | HTTPS/Authenticated | The goal of this task is to demonstrate HTTPS requests with authentication.
Implementations of this task should not use client certificates for this: that is the subject of another task.
| #AutoHotkey | AutoHotkey | iWeb_Init()
pwb := iWeb_newGui(0, 0, 1000, 800)
iWeb_nav(pwb, "http://www.facebook.com/login.php?ref=pf")
iWeb_Term()
iWeb_complete(pwb)
inputbox, email, email
inputbox, pass, password
iWeb_setDomObj(pwb,"Email",email)
iWeb_setDomObj(pwb,"pass",pass)
iWeb_clickDomObj(pwb, "login")
return
#Include iweb.ahk
#Include CO... |
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... | #PHP | PHP |
<?php
function piece_wise($iban_all_digits) {
$remainder = NULL;
$slice = 9;
for ($i=0; $i<strlen($iban_all_digits); $i=$i+$slice)
{
if ($i>0)
{
$slice = 7;
}
$part = $remainder . substr($iban_all_digits, $i, $slice);
//echo "REMAINDER: " .... |
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
⋮
⋮
⋮
⋱
... | #IS-BASIC | IS-BASIC | 100 PROGRAM "Identity.bas"
110 INPUT PROMPT "Enter size of matrix: ":N
120 NUMERIC A(1 TO N,1 TO N)
130 CALL INIT(A)
140 CALL WRITE(A)
150 DEF INIT(REF T)
160 FOR I=LBOUND(T,1) TO UBOUND(T,1)
170 FOR J=LBOUND(T,2) TO UBOUND(T,2)
180 LET T(I,J)=0
190 NEXT
200 LET T(I,I)=1
210 NEXT
220 END DEF
230 D... |
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... | #SuperCollider | SuperCollider |
i = Routine { inf.do { |i| i.yield } }; // return all integers, represented by a 64 bit signed float.
fork { inf.do { i.next.postln; 0.01.wait } }; // this prints them incrementally
|
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... | #Swift | Swift | var i = 0
while true {
println(i++)
} |
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... | #QBasic | QBasic | DEFINT A-Z
DIM W AS STRING
CLS
OPEN "I", 1, "UNIXDICT.TXT"
DO
LINE INPUT #1, W
IF INSTR(W, "ie") THEN IF INSTR(W, "cie") THEN CI = CI + 1 ELSE XI = XI + 1
IF INSTR(W, "ei") THEN IF INSTR(W, "cei") THEN CE = CE + 1 ELSE XE = XE + 1
LOOP WHILE NOT EOF(1)
CLOSE #1
PRINT "CIE:"; CI
PRINT "xIE:"; XI
PRINT "CEI... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Metafont | Metafont | string s;
s := "1234";
s := decimal(scantokens(s)+1);
message s; |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #min | min | (int succ string) :next |
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 |... | #jq | jq | # compare/0 compares the first two items if they are numbers,
# otherwise an "uncomparable" message is emitted.
def compare:
def english:
if .[0] < .[1] then "less than"
elif .[0] == .[1] then "equal to"
else "greater than"
end;
if (.[0]|type) == "number" and (.[1]|type) == "number" then
"... |
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 |... | #Julia | Julia | function compare()
int1 = readline(stdin)
int2 = readline(stdin)
print(int1, " is ",
int1 < int2 ? "less than " :
int1 == int2 ? "equal to " :
int1 > int2 ? "greater than " :
"uncomparable to",
int2)
end
|
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | a = RunThrough["curl -E myCert.pem https://www.example.com", 1]
For[ i=0, i < Length[a] , i++, SomeFunction[a]] |
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #Nim | Nim | import httpclient, net
var client = newHttpClient(sslContext = newContext(certFile = "mycert.pem"))
var r = client.get("https://www.example.com") |
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #Perl | Perl | #!/usr/bin/env perl -T
use 5.018_002;
use warnings;
use LWP;
our $VERSION = 1.000_000;
my $ua = LWP::UserAgent->new(
ssl_opts => {
SSL_cert_file => 'certificate.pem',
SSL_key_file => 'key.pem',
verify_hostname => 1,
}
);
my $req = HTTP::Request->new( GET => 'https://www.example.... |
http://rosettacode.org/wiki/HTTPS/Authenticated | HTTPS/Authenticated | The goal of this task is to demonstrate HTTPS requests with authentication.
Implementations of this task should not use client certificates for this: that is the subject of another task.
| #BaCon | BaCon | OPTION TLS TRUE
website$ = "website.com"
username$ = "nobody"
password$ = "ignore"
OPEN website$ & ":443" FOR NETWORK AS conn
SEND "GET / HTTP/1.1\r\nHost: " & website$ & "\r\nAuthorization: Basic " & B64ENC$(username$ & ":" & password$) & "\r\n\r\n" TO conn
WHILE WAIT(conn, 2000)
RECEIVE data$ FROM conn
... |
http://rosettacode.org/wiki/HTTPS/Authenticated | HTTPS/Authenticated | The goal of this task is to demonstrate HTTPS requests with authentication.
Implementations of this task should not use client certificates for this: that is the subject of another task.
| #C | C | #include <stdio.h>
#include <stdlib.h>
#include "curl/curl.h"
int
main(void)
{
CURL *curl;
char buffer[CURL_ERROR_SIZE];
if ((curl = curl_easy_init()) != NULL) {
curl_easy_setopt(curl, CURLOPT_URL, "https://user:password@secure.example.com/");
curl_easy_setopt... |
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... | #Picat | Picat | go =>
IBAN = "GB82 WEST 1234 5698 7654 32",
println(IBAN=iban(IBAN)),
nl.
iban(IBAN) = Ret =>
nations(Nations),
Ret = [],
IBAN2 = IBAN.delete_all(' ').to_uppercase(),
Len = IBAN2.length,
Len > 2, % sanity check
if Len != Nations.get(slice(IBAN2,1,2),0).to_integer() then
Ret := ["wrong country l... |
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
⋮
⋮
⋮
⋱
... | #J | J | = i. 4 NB. create an Identity matrix of size 4
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
makeI=: =@i. NB. define as a verb with a user-defined name
makeI 5 NB. create an Identity matrix of size 5
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 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... | #Symsyn | Symsyn |
| The following code will run forever
| Symsyn uses a 64 bit signed integer
| The largest positive integer is 9223372036854775807
| lpi + 1 = -9223372036854775808
lp
x []
+ x
go lp
|
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... | #Tcl | Tcl | package require Tcl 8.5
while true {puts [incr i]} |
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... | #R | R | words = tolower(readLines("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"))
ie.npc = sum(grepl("(?<!c)ie", words, perl = T))
ei.npc = sum(grepl("(?<!c)ei", words, perl = T))
ie.pc = sum(grepl("cie", words, fixed = T))
ei.pc = sum(grepl("cei", words, fixed = T))
p1 = ie.npc > 2 * ei.npc
p2 = ei.pc > 2 * ie.pc
... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #mIRC_Scripting_Language | mIRC Scripting Language | var %n = 12345
inc %n
echo -ag %n |
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 |... | #Kotlin | Kotlin | fun main(args: Array<String>) {
val n1 = readLine()!!.toLong()
val n2 = readLine()!!.toLong()
println(when {
n1 < n2 -> "$n1 is less than $n2"
n1 > n2 -> "$n1 is greater than $n2"
n1 == n2 -> "$n1 is equal to $n2"
else -> ""
})
} |
http://rosettacode.org/wiki/HTTPS/Client-authenticated | HTTPS/Client-authenticated | Demonstrate how to connect to a web server over HTTPS where that server requires that the client present a certificate to prove who (s)he is. Unlike with the HTTPS request with authentication task, it is not acceptable to perform the authentication by a username/password or a set cookie.
This task is in general useful... | #Phix | Phix | without js
include builtins\libcurl.e
curl_global_init()
atom curl = curl_easy_init()
curl_easy_setopt(curl, CURLOPT_URL, "https://sourceforge.net")
integer fn = open("myCert.pem","r")
curl_easy_setopt(curl, CURLOPT_SSLCERT, get_text(fn))
close(fn)
object res = curl_easy_perform_ex(curl)
curl_easy_cleanup(curl)
curl_gl... |
http://rosettacode.org/wiki/HTTPS/Authenticated | HTTPS/Authenticated | The goal of this task is to demonstrate HTTPS requests with authentication.
Implementations of this task should not use client certificates for this: that is the subject of another task.
| #C.23 | C# |
using System;
using System.Net;
class Program
{
static void Main(string[] args)
{
var client = new WebClient();
// credentials of current user:
client.Credentials = CredentialCache.DefaultCredentials;
// or specify credentials manually:
client.Credentials = new Netw... |
http://rosettacode.org/wiki/HTTPS/Authenticated | HTTPS/Authenticated | The goal of this task is to demonstrate HTTPS requests with authentication.
Implementations of this task should not use client certificates for this: that is the subject of another task.
| #Clojure | Clojure | (clj-http.client/get "https://somedomain.com"
{:basic-auth ["user" "pass"]}) |
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... | #PicoLisp | PicoLisp | (setq *Sizes '((GB . 22) (CH . 21) (SA . 24)))
(de iban (Str)
(let Lst
(filter
'((X) (not (sp? X)))
(chop (uppc Str)) )
(when
(=
(cdr (assoc (pack (head 2 Lst)) *Sizes))
(length Lst) )
(%
(format
(mapcar
... |
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
⋮
⋮
⋮
⋱
... | #Java | Java | public class PrintIdentityMatrix {
public static void main(String[] args) {
int n = 5;
int[][] array = new int[n][n];
IntStream.range(0, n).forEach(i -> array[i][i] = 1);
Arrays.stream(array)
.map((int[] a) -> Arrays.toString(a))
.forEach(System.... |
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... | #Tiny_BASIC | Tiny BASIC |
REM will overflow after 32767
LET N = 0
10 PRINT N
LET N = N + 1
GOTO 10
|
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... | #True_BASIC | True BASIC | LET i = 0
DO
PRINT i
LET i = i + 1
LOOP
END |
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... | #Racket | Racket | #lang racket
(define (get-tallies filename line-parser . patterns)
(for/fold ([totals (make-list (length patterns) 0)])
([line (file->lines filename)])
(match-let ([(list word n) (line-parser line)])
(for/list ([p patterns] [t totals])
(if (regexp-match? p word)
(+ n t) t)))))
(... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #ML | ML | ntos ` ston "1234" + 1;
|
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Modula-2 | Modula-2 | MODULE addstr;
IMPORT InOut, NumConv, Strings;
VAR str1, str2 : Strings.String;
num : CARDINAL;
ok : BOOLEAN;
BEGIN
str1 := "12345";
InOut.Write ('"'); InOut.WriteString (str1); InOut.WriteString ('" + 1 = ');
NumConv.Str2Num (num, 10, str1, ok);
... |
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 |... | #Lambdatalk | Lambdatalk |
{def compare
{lambda {:a :b}
{if {< :a :b}
then :a is lesser than :b
else {if {> :a :b}
then :a is greater than :b
else :a is equal to :b}}}}
{compare 1 2}
-> 1 is lesser than 2
{compare 2 1}
-> 2 is greater than 1
{compare 1 1}
-> 1 is equal to 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.