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/Luhn_test_of_credit_card_numbers
Luhn test of credit card numbers
The Luhn test is used by some credit card companies to distinguish valid credit card numbers from what could be a random selection of digits. Those companies using credit card numbers that can be validated by the Luhn test have numbers that pass the following test: Reverse the order of the digits in the number. Tak...
#ZX_Spectrum_Basic
ZX Spectrum Basic
10 LET c$="49927398716": GO SUB 1000 20 LET c$="49927398717": GO SUB 1000 30 LET c$="1234567812345678": GO SUB 1000 40 LET c$="1234567812345670": GO SUB 1000 999 STOP 1000 REM ************* 1001 REM * LUHN TEST * 1002 REM ************* 1010 LET r$="" 1020 FOR i=LEN c$ TO 1 STEP -1 1030 LET r$=r$+c$(i) 1040 NEXT i 1050...
http://rosettacode.org/wiki/Loops/For
Loops/For
“For”   loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code. Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers. ...
#Morfa
Morfa
  import morfa.base;   for (i in 0..5) { for (j in 0..i+1) { print("*"); } println(""); }  
http://rosettacode.org/wiki/Loops/For_with_a_specified_step
Loops/For with a specified step
Task Demonstrate a   for-loop   where the step-value is greater than one. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while   Loops/Downward for   Loops/For   Loops/For with a specified step   Loops/Foreach   Loops/Increment loop index within loop b...
#Vlang
Vlang
for i := 1; i<10; i+=2 { println(i) }
http://rosettacode.org/wiki/Loops/For_with_a_specified_step
Loops/For with a specified step
Task Demonstrate a   for-loop   where the step-value is greater than one. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while   Loops/Downward for   Loops/For   Loops/For with a specified step   Loops/Foreach   Loops/Increment loop index within loop b...
#Vorpal
Vorpal
for(i = 2, i <= 8, i = i + 2){ i.print() }
http://rosettacode.org/wiki/Long_multiplication
Long multiplication
Task Explicitly implement   long multiplication. This is one possible approach to arbitrary-precision integer algebra. For output, display the result of   264 * 264. Optionally, verify your result against builtin arbitrary precision support. The decimal representation of   264   is: 18,446,744,073,709,551,61...
#Python
Python
#!/usr/bin/env python print 2**64*2**64
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#UNIX_Shell
UNIX Shell
echo "The boy said 'hello'." echo 'The girl said "hello" too.'
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#Ursala
Ursala
a = `x
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#V
V
'hello world' puts
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Stata
Stata
let hex = 0x2F // Hexadecimal let bin = 0b101111 // Binary let oct = 0o57 // Octal
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Swift
Swift
let hex = 0x2F // Hexadecimal let bin = 0b101111 // Binary let oct = 0o57 // Octal
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#NewLISP
NewLISP
  (define (logic a b) (print "a and b is: " (and a b) "\n a or b is: " (or a b)) (print "\n not a is: " (not a)))    
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#Nim
Nim
proc logic(a, b: bool) = echo "a and b: ", a and b echo "a or b: ", a or b echo "not a: ", not a echo "a xor b: ", a xor b
http://rosettacode.org/wiki/Loop_over_multiple_arrays_simultaneously
Loop over multiple arrays simultaneously
Task Loop over multiple arrays   (or lists or tuples or whatever they're called in your language)   and display the   i th   element of each. Use your language's   "for each"   loop if it has one, otherwise iterate through the collection in order with some other loop. For this example, loop over the arrays: ...
#Liberty_BASIC
Liberty BASIC
a$(1)="a" : a$(2)="b" : a$(3)="c" b$(1)="A" : b$(2)="B" : b$(3)="C" c(1)=1 : c(2)=2 : c(3)=3     for i = 1 to 3 print a$(i);b$(i);c(i) next
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#Plain_English
Plain English
To run: Start up. Demonstrate breaking. Wait for the escape key. Shut down.   To demonstrate breaking: Pick a number between 0 and 19. Write the number to the console. If the number is 10, break. Pick another number between 0 and 19. Write the other number to the console. Repeat.   To write a number to the console: Con...
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#PostScript
PostScript
realtime srand  % init RNG { rand 20 mod  % generate number between 0 and 19 dup =  % print it 10 eq { exit } if  % exit if 10 } loop
http://rosettacode.org/wiki/Longest_common_subsequence
Longest common subsequence
Introduction Define a subsequence to be any output string obtained by deleting zero or more symbols from an input string. The Longest Common Subsequence (LCS) is a subsequence of maximum length common to two or more strings. Let A ≡ A[0]… A[m - 1] and B ≡ B[0]… B[n - 1], m < n be strings drawn from an alphabet Σ of ...
#Swift
Swift
rlcs(_ s1: String, _ s2: String) -> String { if s1.count == 0 || s2.count == 0 { return "" } else if s1[s1.index(s1.endIndex, offsetBy: -1)] == s2[s2.index(s2.endIndex, offsetBy: -1)] { return rlcs(String(s1[s1.startIndex..<s1.index(s1.endIndex, offsetBy: -1)]), String(s2[s2.start...
http://rosettacode.org/wiki/Look-and-say_sequence
Look-and-say sequence
The   Look and say sequence   is a recursively defined sequence of numbers studied most notably by   John Conway. The   look-and-say sequence   is also known as the   Morris Number Sequence,   after cryptographer Robert Morris,   and the puzzle   What is the next number in the sequence 1,   11,   21,   1211,   11122...
#Nim
Nim
iterator lookAndSay(n: int): string = var current = "1" yield current for round in 2..n: var ch = current[0] var count = 1 var next = "" for i in 1..current.high: if current[i] == ch: inc count else: next.add $count & ch ch = current[i] count = 1 cur...
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#Vala
Vala
for (int i = 1; i <= 10; i++) { stdout.printf("%d", i); if (i % 5 == 0) { stdout.printf("\n"); continue; } stdout.printf(", "); }
http://rosettacode.org/wiki/Loops/For
Loops/For
“For”   loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code. Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers. ...
#MUMPS
MUMPS
FORLOOP NEW I,J FOR I=1:1:5 DO .FOR J=1:1:I DO ..WRITE "*" .WRITE ! QUIT
http://rosettacode.org/wiki/Loops/For_with_a_specified_step
Loops/For with a specified step
Task Demonstrate a   for-loop   where the step-value is greater than one. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while   Loops/Downward for   Loops/For   Loops/For with a specified step   Loops/Foreach   Loops/Increment loop index within loop b...
#Wart
Wart
for i 2 (i <= 8) (i <- i+2) prn i
http://rosettacode.org/wiki/Loops/For_with_a_specified_step
Loops/For with a specified step
Task Demonstrate a   for-loop   where the step-value is greater than one. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while   Loops/Downward for   Loops/For   Loops/For with a specified step   Loops/Foreach   Loops/Increment loop index within loop b...
#Wren
Wren
// Print odd numbers under 20. for (i in 1..10) { var j = 2*i - 1 System.write("%(j) ") }   System.print("\n")   // Do the same using a 'while' loop. var k = 1 while (k < 20) { System.write("%(k) ") k = k + 2 } System.print()
http://rosettacode.org/wiki/Long_multiplication
Long multiplication
Task Explicitly implement   long multiplication. This is one possible approach to arbitrary-precision integer algebra. For output, display the result of   264 * 264. Optionally, verify your result against builtin arbitrary precision support. The decimal representation of   264   is: 18,446,744,073,709,551,61...
#Quackery
Quackery
( ------------- preamble to task, some i/o related words ------------- )   [ [] swap witheach [ char 0 - swap join ] ] is $->long ( $ --> L )   [ number$ $->long ] is long ( n --> L )   [ reverse behead swap witheach [ swap 10 * +...
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#Vim_Script
Vim Script
Debug.Print "Tom said, ""The fox ran away.""" Debug.Print "Tom said, 'The fox ran away.'"
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#Visual_Basic
Visual Basic
Debug.Print "Tom said, ""The fox ran away.""" Debug.Print "Tom said, 'The fox ran away.'"
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Tcl
Tcl
% expr 727 == 0x2d7 1 % expr 727 == 0o1327 1 % expr 727 == 01327 1 % expr 727 == 0b1011010111 1
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#TI-89_BASIC
TI-89 BASIC
0b10000001 = 129 = 0h81
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#Objeck
Objeck
  bundle Default { class Logic { function : Main(args : String[]) ~ Nil { a := true; b := false; IO.Console->GetInstance()->Print("a and b is: ")->PrintLine(a & b); IO.Console->GetInstance()->Print("a or b is: ")->PrintLine(a | b); IO.Console->GetInstance()->Print("not a is: ")->Prin...
http://rosettacode.org/wiki/Loop_over_multiple_arrays_simultaneously
Loop over multiple arrays simultaneously
Task Loop over multiple arrays   (or lists or tuples or whatever they're called in your language)   and display the   i th   element of each. Use your language's   "for each"   loop if it has one, otherwise iterate through the collection in order with some other loop. For this example, loop over the arrays: ...
#Lisaac
Lisaac
Section Header   + name := ARRAY_LOOP_TEST;   Section Public   - main <- ( + a1, a2 : ARRAY[CHARACTER]; + a3 : ARRAY[INTEGER];   a1 := ARRAY[CHARACTER].create 1 to 3; a2 := ARRAY[CHARACTER].create 1 to 3; a3 := ARRAY[INTEGER].create 1 to 3;   1.to 3 do { i : INTEGER; a1.put ((i - 1 + 'a'.code).to_charac...
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#PowerShell
PowerShell
$r = New-Object Random for () { $n = $r.Next(20) Write-Host $n if ($n -eq 10) { break } Write-Host $r.Next(20) }
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#PureBasic
PureBasic
If OpenConsole()   Repeat a = Random(19) PrintN(Str(a)) If a = 10 Break EndIf b = Random(19) PrintN(Str(b)) PrintN("") ForEver   Print(#CRLF$ + #CRLF$ + "Press ENTER to exit") Input() CloseConsole() EndIf
http://rosettacode.org/wiki/Longest_common_subsequence
Longest common subsequence
Introduction Define a subsequence to be any output string obtained by deleting zero or more symbols from an input string. The Longest Common Subsequence (LCS) is a subsequence of maximum length common to two or more strings. Let A ≡ A[0]… A[m - 1] and B ≡ B[0]… B[n - 1], m < n be strings drawn from an alphabet Σ of ...
#Tcl
Tcl
proc r_lcs {a b} { if {$a eq "" || $b eq ""} {return ""} set a_ [string range $a 1 end] set b_ [string range $b 1 end] if {[set c [string index $a 0]] eq [string index $b 0]} { return "$c[r_lcs $a_ $b_]" } else { set x [r_lcs $a $b_] set y [r_lcs $a_ $b] return [expr ...
http://rosettacode.org/wiki/Look-and-say_sequence
Look-and-say sequence
The   Look and say sequence   is a recursively defined sequence of numbers studied most notably by   John Conway. The   look-and-say sequence   is also known as the   Morris Number Sequence,   after cryptographer Robert Morris,   and the puzzle   What is the next number in the sequence 1,   11,   21,   1211,   11122...
#Objective-C
Objective-C
#import <Foundation/Foundation.h>   -(NSString*)lookAndSay:(NSString *)word{ if (!word) { return nil; } NSMutableString *result = [NSMutableString new];   char repeat = [word characterAtIndex:0]; int times = 1; word = [NSString stringWithFormat:@"%@ ",[word substringFromIndex:1] ];   ...
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#VBA
VBA
Public Sub LoopContinue() Dim value As Integer For value = 1 To 10 Debug.Print value; If value Mod 5 = 0 Then 'VBA does not have a continue statement Debug.Print Else Debug.Print ","; End If Next value End Sub
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#Vedit_macro_language
Vedit macro language
for (#1 = 1; #1 <= 10; #1++) { Num_Type(#1, LEFT+NOCR) if (#1 % 5 == 0) { Type_Newline Continue } Message(", ") }
http://rosettacode.org/wiki/Loops/For
Loops/For
“For”   loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code. Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers. ...
#Nanoquery
Nanoquery
for ($i = 1) ($i <= 5) ($i = $i+1) for ($j = 0) ($j < $i) ($j = $j+1) print "*" end for println end for
http://rosettacode.org/wiki/Loops/For_with_a_specified_step
Loops/For with a specified step
Task Demonstrate a   for-loop   where the step-value is greater than one. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while   Loops/Downward for   Loops/For   Loops/For with a specified step   Loops/Foreach   Loops/Increment loop index within loop b...
#XPL0
XPL0
include c:\cxpl\codes; int I; [for I:= 2 to 8 do [IntOut(0, I); Text(0, ", "); I:= I+1; ]; Text(0, "who do we appreciate?"); ]
http://rosettacode.org/wiki/Loops/For_with_a_specified_step
Loops/For with a specified step
Task Demonstrate a   for-loop   where the step-value is greater than one. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while   Loops/Downward for   Loops/For   Loops/For with a specified step   Loops/Foreach   Loops/Increment loop index within loop b...
#zkl
zkl
foreach n in ([1..10,4]) {println(n)} [1..10,3].pump(Console.println)
http://rosettacode.org/wiki/Long_multiplication
Long multiplication
Task Explicitly implement   long multiplication. This is one possible approach to arbitrary-precision integer algebra. For output, display the result of   264 * 264. Optionally, verify your result against builtin arbitrary precision support. The decimal representation of   264   is: 18,446,744,073,709,551,61...
#R
R
library(gmp) a <- as.bigz("18446744073709551616") mul.bigz(a,a)
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#Visual_Basic_.NET
Visual Basic .NET
Dim s = "Tom said, ""The fox ran away.""" Result: Tom said, "The fox ran away."
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#WEB
WEB
var s = "abc123" var t = "abc\t123\%" var u = "\U0001F64A\U0001F680" var v = "%("abc" * 3)" var w = """a"bc""def\n%(v)"""   System.print([s, t, u, v, w])
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#UNIX_Shell
UNIX Shell
$ expr 700 - 1 699 $ expr 0700 - 01 699
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Ursa
Ursa
decl int i set i 123 set i -456
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#OCaml
OCaml
let print_logic a b = Printf.printf "a and b is %B\n" (a && b); Printf.printf "a or b is %B\n" (a || b); Printf.printf "not a is %B\n" (not a)
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#Octave
Octave
function test(a, b) s1 = num2str(a); s2 = num2str(b); disp(strcat(s1, " and ", s2, " = ", num2str(a&&b))); disp(strcat(s1, " or ", s2, " = ", num2str(a||b))); disp(strcat("not ", s1, " = ", num2str(!a))); endfunction   % constant true is 1, false is 0 test(true, true); test(false, false); test(true, false); t...
http://rosettacode.org/wiki/Loop_over_multiple_arrays_simultaneously
Loop over multiple arrays simultaneously
Task Loop over multiple arrays   (or lists or tuples or whatever they're called in your language)   and display the   i th   element of each. Use your language's   "for each"   loop if it has one, otherwise iterate through the collection in order with some other loop. For this example, loop over the arrays: ...
#LiveCode
LiveCode
command loopArrays local lowA, uppA, nums, z put "a,b,c" into lowA put "A,B,C" into uppA put "1,2,3" into nums   split lowA by comma split uppA by comma split nums by comma   repeat with n = 1 to the number of elements of lowA put lowA[n] & uppA[n] & nums[n] & return after z ...
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#Python
Python
from random import randrange   while True: a = randrange(20) print(a) if a == 10: break b = randrange(20) print(b)
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#QB64
QB64
RANDOMIZE TIMER DO n = INT(RND * 20) PRINT n, IF n = 10 THEN EXIT DO ELSE n = INT(RND * 20) PRINT n END IF LOOP UNTIL 0
http://rosettacode.org/wiki/Longest_common_subsequence
Longest common subsequence
Introduction Define a subsequence to be any output string obtained by deleting zero or more symbols from an input string. The Longest Common Subsequence (LCS) is a subsequence of maximum length common to two or more strings. Let A ≡ A[0]… A[m - 1] and B ≡ B[0]… B[n - 1], m < n be strings drawn from an alphabet Σ of ...
#Ursala
Ursala
#import std   lcs = ~&alrB^& ~&E?abh/~&alh2fabt2RC @faltPrXlrtPXXPW leql?/~&r ~&l
http://rosettacode.org/wiki/Look-and-say_sequence
Look-and-say sequence
The   Look and say sequence   is a recursively defined sequence of numbers studied most notably by   John Conway. The   look-and-say sequence   is also known as the   Morris Number Sequence,   after cryptographer Robert Morris,   and the puzzle   What is the next number in the sequence 1,   11,   21,   1211,   11122...
#OCaml
OCaml
let rec seeAndSay = function | [], nys -> List.rev nys | x::xs, [] -> seeAndSay(xs, [x; 1]) | x::xs, y::n::nys when x=y -> seeAndSay(xs, y::1+n::nys) | x::xs, nys -> seeAndSay(xs, x::1::nys)
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#Vlang
Vlang
fn main() { for i in 1..11 { print(i) if i%5==0{ println('') continue } print(', ') } }
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#Wren
Wren
for (i in 1..10) { System.write(i) if (i%5 == 0) { System.print() continue } System.write(", ") }   System.print()
http://rosettacode.org/wiki/Loops/For
Loops/For
“For”   loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code. Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers. ...
#Nemerle
Nemerle
for (int i = 0; i < 5; i++) { for (int j = 0; j <= i; j++) { Write("*"); } WriteLine(); }
http://rosettacode.org/wiki/Loops/For_with_a_specified_step
Loops/For with a specified step
Task Demonstrate a   for-loop   where the step-value is greater than one. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while   Loops/Downward for   Loops/For   Loops/For with a specified step   Loops/Foreach   Loops/Increment loop index within loop b...
#Zig
Zig
const std = @import("std");   pub fn main() !void { const stdout_wr = std.io.getStdOut().writer(); var i: u8 = 1; while (i < 10) : (i += 2) try stdout_wr.print("{d}\n", .{i}); }
http://rosettacode.org/wiki/Long_multiplication
Long multiplication
Task Explicitly implement   long multiplication. This is one possible approach to arbitrary-precision integer algebra. For output, display the result of   264 * 264. Optionally, verify your result against builtin arbitrary precision support. The decimal representation of   264   is: 18,446,744,073,709,551,61...
#Racket
Racket
  #lang racket   (define (mult A B) (define nums (let loop ([B B] [zeros '()]) (if (null? B) '() (cons (append zeros (let loop ([c 0] [A A]) (cond [(pair? A) (define-values [q r] (quotie...
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#Wren
Wren
var s = "abc123" var t = "abc\t123\%" var u = "\U0001F64A\U0001F680" var v = "%("abc" * 3)" var w = """a"bc""def\n%(v)"""   System.print([s, t, u, v, w])
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#Xojo
Xojo
Dim s As String = "Tom said, ""The fox ran away.""" Result: Tom said, "The fox ran away."
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#XPL0
XPL0
The literal value of a character is specified by preceding it with a caret. For example, this assigns the ASCII value of A (hex 41) to Ch: Ch:= ^A; Strings are one-dimensional byte arrays. For example, this assigns the address of the string enclosed in quote marks to Str: Str:= "Hello, world!"; The ASCII code for ...
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Ursala
Ursala
n = 724
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Verbexx
Verbexx
// Integer Literals: // // If present, base prefix must be: 0b 0B (binary) 0o 0O (octal) // 0x 0X (hex) // // If present, length suffix must be: i I i64 I64 (INT64_T) // u U u64 U64 (UINT64_T) // ...
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#Oforth
Oforth
: logical(b1, b2) System.Out "and = " << b1 b2 and << cr System.Out "or = " << b1 b2 or << cr System.Out "xor = " << b1 b2 xor << cr System.Out "not = " << b1 not << cr ;
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#OOC
OOC
  logic: func (a: Bool, b: Bool) { println() "A=#{a}, B=#{b}:" println() "AND: #{a && b}" println() "OR: #{a || b}" println() "NOT A: #{!a}" println() }   main: func { logic(true, false) logic(true, true) logic(false, false) logic(false, true) }  
http://rosettacode.org/wiki/Loop_over_multiple_arrays_simultaneously
Loop over multiple arrays simultaneously
Task Loop over multiple arrays   (or lists or tuples or whatever they're called in your language)   and display the   i th   element of each. Use your language's   "for each"   loop if it has one, otherwise iterate through the collection in order with some other loop. For this example, loop over the arrays: ...
#Logo
Logo
show (map [(word ?1 ?2 ?3)] [a b c] [A B C] [1 2 3])  ; [aA1 bB2 cC3]   (foreach [a b c] [A B C] [1 2 3] [print (word ?1 ?2 ?3)])  ; as above, one per line
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#Qi
Qi
  (define loop -> (if (= 10 (PRINT (random 20))) true (do (PRINT (random 20)) (loop)))) (loop)  
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#Quackery
Quackery
[ 20 random dup echo sp 10 = if done 20 random echo cr again ]
http://rosettacode.org/wiki/Longest_common_subsequence
Longest common subsequence
Introduction Define a subsequence to be any output string obtained by deleting zero or more symbols from an input string. The Longest Common Subsequence (LCS) is a subsequence of maximum length common to two or more strings. Let A ≡ A[0]… A[m - 1] and B ≡ B[0]… B[n - 1], m < n be strings drawn from an alphabet Σ of ...
#Wren
Wren
var lcs // recursive lcs = Fn.new { |x, y| if (x.count == 0 || y.count == 0) return "" var x1 = x[0...-1] var y1 = y[0...-1] if (x[-1] == y[-1]) return lcs.call(x1, y1) + x[-1] var x2 = lcs.call(x, y1) var y2 = lcs.call(x1, y) return (x2.count > y2.count) ? x2 : y2 }   var x = "thisisatest" ...
http://rosettacode.org/wiki/Look-and-say_sequence
Look-and-say sequence
The   Look and say sequence   is a recursively defined sequence of numbers studied most notably by   John Conway. The   look-and-say sequence   is also known as the   Morris Number Sequence,   after cryptographer Robert Morris,   and the puzzle   What is the next number in the sequence 1,   11,   21,   1211,   11122...
#Oforth
Oforth
import: mapping   : lookAndSay ( n -- ) [ 1 ] #[ dup .cr group map( [#size, #first] ) expand ] times( n ) ;
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#X86_Assembly
X86 Assembly
  extern _printf   section .data output db 0,0,0,0 reversedOutput db 0,0   section .text global _main _main: mov ecx, 0 looping: inc ecx mov eax, ecx push ecx cmp ecx, 5 je do5 cmp ecx, 10 je do10 don: call createOutput mov [eax...
http://rosettacode.org/wiki/Loops/For
Loops/For
“For”   loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code. Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers. ...
#NetRexx
NetRexx
/* NetRexx */ options replace format comments java crossref savelog symbols nobinary   say say 'Loops/For'   loop i_ = 1 to 5 loop for i_ say '*\-' end say end i_  
http://rosettacode.org/wiki/Long_multiplication
Long multiplication
Task Explicitly implement   long multiplication. This is one possible approach to arbitrary-precision integer algebra. For output, display the result of   264 * 264. Optionally, verify your result against builtin arbitrary precision support. The decimal representation of   264   is: 18,446,744,073,709,551,61...
#Raku
Raku
sub num_to_groups ( $num ) { $num.flip.comb(/.**1..4/)».flip }; sub groups_to_num ( @g ) { [~] flat @g.pop, @g.reverse».fmt('%04d') };   sub long_multiply ( Str $x, Str $y ) { my @group_sums; for flat num_to_groups($x).pairs X num_to_groups($y).pairs -> $xp, $yp { @group_sums[ $xp.key + $yp.key ] ...
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#XSLT
XSLT
<xsl:if test="starts-with(@name, 'Mr.')">Mister</xsl:if>
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#Z80_Assembly
Z80 Assembly
db "Hello World"
http://rosettacode.org/wiki/Literals/String
Literals/String
Task Show literal specification of characters and strings. If supported, show how the following work:   verbatim strings   (quotes where escape sequences are quoted literally)   here-strings   Also, discuss which quotes expand variables. Related tasks   Special characters   Here document Other tasks r...
#zkl
zkl
text:= 0'|foo| "bar\n";
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Visual_Basic
Visual Basic
Sub Main()   'Long: 4 Bytes (signed), type specifier = & Dim l1 As Long, l2 As Long, l3 As Long 'Integer: 2 Bytes (signed), type specifier = % Dim i1 As Integer, i2 As Integer, i3 As Integer 'Byte: 1 Byte (unsigned), no type specifier Dim b1 As Byte, b2 As Byte, b3 As Byte   l1 = 1024& l2 = &H400& l3 = &O20...
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Wren
Wren
var a = 255 var b = 0xff var c = 0255 // not an octal literal var d = 2.55e2 System.print([a, b, c, d])
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#OpenEdge.2FProgress
OpenEdge/Progress
FUNCTION testLogical RETURNS CHAR ( i_l1 AS LOGICAL, i_l2 AS LOGICAL ):   RETURN SUBSTITUTE( '&1 and &2: &3', i_l1, i_l2, i_l1 AND i_l2 ) + '~n' + SUBSTITUTE( '&1 or &2: &3', i_l1, i_l2, i_l1 OR i_l2 ) + '~n' + SUBSTITUTE( 'not &1: &2', i_l1, NOT i_l1 ) .   END FUNCTION.
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#Oz
Oz
proc {PrintLogic A B} %% using not short-circuiting standard library functions {Show {And A B}} {Show {Or A B}} {Show {Not A}}   %% using short-circuiting keywords {Show A andthen B} {Show A orelse B} end
http://rosettacode.org/wiki/Loop_over_multiple_arrays_simultaneously
Loop over multiple arrays simultaneously
Task Loop over multiple arrays   (or lists or tuples or whatever they're called in your language)   and display the   i th   element of each. Use your language's   "for each"   loop if it has one, otherwise iterate through the collection in order with some other loop. For this example, loop over the arrays: ...
#Lua
Lua
  a1, a2, a3 = {'a' , 'b' , 'c' } , { 'A' , 'B' , 'C' } , { 1 , 2 , 3 } for i = 1, 3 do print(a1[i]..a2[i]..a3[i]) end  
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#R
R
sample0to19 <- function() sample(0L:19L, 1,replace=TRUE) repeat { result1 <- sample0to19() if (result1 == 10L) { print(result1) break } result2 <- sample0to19() cat(result1, result2, "\n") }
http://rosettacode.org/wiki/Longest_common_subsequence
Longest common subsequence
Introduction Define a subsequence to be any output string obtained by deleting zero or more symbols from an input string. The Longest Common Subsequence (LCS) is a subsequence of maximum length common to two or more strings. Let A ≡ A[0]… A[m - 1] and B ≡ B[0]… B[n - 1], m < n be strings drawn from an alphabet Σ of ...
#zkl
zkl
fcn lcs(a,b){ if(not a or not b) return(""); if (a[0]==b[0]) return(a[0] + self.fcn(a[1,*],b[1,*])); return(fcn(x,y){if(x.len()>y.len())x else y}(lcs(a,b[1,*]),lcs(a[1,*],b))) }
http://rosettacode.org/wiki/Look-and-say_sequence
Look-and-say sequence
The   Look and say sequence   is a recursively defined sequence of numbers studied most notably by   John Conway. The   look-and-say sequence   is also known as the   Morris Number Sequence,   after cryptographer Robert Morris,   and the puzzle   What is the next number in the sequence 1,   11,   21,   1211,   11122...
#Oz
Oz
declare %% e.g. "21" -> "1211" fun {LookAndSayString S} for DigitGroup in {Group S} append:Add do {Add {Int.toString {Length DigitGroup}}} {Add [DigitGroup.1]} end end   %% lazy sequence of integers starting with N fun {LookAndSay N} fun lazy {Loop S} {String.toInt S}|{L...
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#XBasic
XBasic
  PROGRAM "loopcontinue"   DECLARE FUNCTION Entry()   FUNCTION Entry() FOR i% = 1 TO 10 PRINT i%; IF i% MOD 5 = 0 THEN PRINT DO NEXT ' It looks like DO FOR backs to the FOR with the current value of i% END IF PRINT ", "; NEXT i% END FUNCTION END PROGRAM  
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#XPL0
XPL0
code CrLf=9, IntOut=11, Text=12; integer N; for N:= 1 to 10 do [IntOut(0, N); if remainder(N/5) \#0\ then Text(0, ", ") else CrLf(0)]
http://rosettacode.org/wiki/Loops/For
Loops/For
“For”   loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code. Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers. ...
#NewLISP
NewLISP
  (for (i 1 5) (for(j 1 i) (print "*")) (print "\n"))  
http://rosettacode.org/wiki/Long_multiplication
Long multiplication
Task Explicitly implement   long multiplication. This is one possible approach to arbitrary-precision integer algebra. For output, display the result of   264 * 264. Optionally, verify your result against builtin arbitrary precision support. The decimal representation of   264   is: 18,446,744,073,709,551,61...
#REXX
REXX
/*REXX program performs long multiplication on two numbers (without the "E"). */ numeric digits 300 /*be able to handle gihugeic input #s. */ parse arg x y . /*obtain optional arguments from the CL*/ if x=='' | x=="," then x= 2**64 ...
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#XPL0
XPL0
code CrLf=9, IntOut=11; def A=123, B=$123, C=%11_0011, D=^A; [IntOut(0, A); CrLf(0); \decimal IntOut(0, B); CrLf(0); \hex IntOut(0, C); CrLf(0); \binary IntOut(0, D); CrLf(0); \ASCII ]
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#Z80_Assembly
Z80 Assembly
byte &55 ;hexadecimal 55 byte $42 ;hexadecimal 42 byte 33 ;decimal 33 byte %00001111 ;binary equivalent of &0F
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#PARI.2FGP
PARI/GP
logic(a,b)={ print(a&b); \\ && is the same print(a|b); \\ || is the same print(!a); };
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#Pascal
Pascal
procedure printlogic(a, b: boolean); begin writeln('a and b is ', a and b); writeln('a or b is ', a or b); writeln('not a is', not a); end;
http://rosettacode.org/wiki/Loop_over_multiple_arrays_simultaneously
Loop over multiple arrays simultaneously
Task Loop over multiple arrays   (or lists or tuples or whatever they're called in your language)   and display the   i th   element of each. Use your language's   "for each"   loop if it has one, otherwise iterate through the collection in order with some other loop. For this example, loop over the arrays: ...
#Maple
Maple
# Set up L := [["a", "b", "c"],["A", "B", "C"], ["1", "2", "3"]]; M := Array(1..3, 1..3, L);   multi_loop := proc(M) local i, j; for i from 1 to upperbound(M, 1) do for j from 1 to upperbound(M, 2) do printf("%s", M[j, i]); end do; printf("\n"); end do; end proc:   multi_loop(M);
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#Racket
Racket
  #lang racket (let loop () (let/ec break (define a (random 20)) (displayln a) (when (= a 10) (break)) (displayln (random 20)) (loop)))  
http://rosettacode.org/wiki/Loops/Break
Loops/Break
Task Show a loop which prints random numbers (each number newly generated each loop) from 0 to 19 (inclusive). If a number is 10, stop the loop after printing it, and do not generate any further numbers. Otherwise, generate and print a second random number before restarting the loop. If the number 10 is never gener...
#Raku
Raku
loop { say my $n = (0..19).pick; last if $n == 10; say (0..19).pick; }
http://rosettacode.org/wiki/Look-and-say_sequence
Look-and-say sequence
The   Look and say sequence   is a recursively defined sequence of numbers studied most notably by   John Conway. The   look-and-say sequence   is also known as the   Morris Number Sequence,   after cryptographer Robert Morris,   and the puzzle   What is the next number in the sequence 1,   11,   21,   1211,   11122...
#PARI.2FGP
PARI/GP
step(n)={ my(v=eval(Vec(Str(n))),cur=v[1],ct=1,out=""); v=concat(v,99); for(i=2,#v, if(v[i]==cur, ct++ , out=Str(out,ct,cur); cur=v[i]; ct=1 ) ); eval(out) }; n=1;for(i=1,20,print(n);n=step(n))
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#Yabasic
Yabasic
for i = 1 to 10 print str$(i); if mod(i, 5) = 0 then print continue end if print ", "; next print end
http://rosettacode.org/wiki/Loops/Continue
Loops/Continue
Task Show the following output using one loop. 1, 2, 3, 4, 5 6, 7, 8, 9, 10 Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it. Related tasks   Loop over multiple arrays simultaneously   Loops/Break   Loops/Continue   Loops/Do-while...
#zkl
zkl
foreach n in ([1..10]){print(n); if(n%5==0){println(); continue;} print(", ")} // or foreach n in ([1..10]){print(n,(n%5) and ", " or "\n")}
http://rosettacode.org/wiki/Loops/For
Loops/For
“For”   loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integer value for each execution of the block of code. Common extensions of this allow other counting patterns or iterating over abstract structures other than the integers. ...
#Nim
Nim
for i in 1..5: for j in 1..i: stdout.write("*") echo("")
http://rosettacode.org/wiki/Long_multiplication
Long multiplication
Task Explicitly implement   long multiplication. This is one possible approach to arbitrary-precision integer algebra. For output, display the result of   264 * 264. Optionally, verify your result against builtin arbitrary precision support. The decimal representation of   264   is: 18,446,744,073,709,551,61...
#Ring
Ring
  decimals(0) see pow(2,64)*pow(2,64) + nl  
http://rosettacode.org/wiki/Literals/Integer
Literals/Integer
Some programming languages have ways of expressing integer literals in bases other than the normal base ten. Task Show how integer literals can be expressed in as many bases as your language allows. Note:   this should not involve the calling of any functions/methods, but should be interpreted by the compiler or...
#zkl
zkl
123, 0d1_000 0x123, 0x12|34 0b1111|0000
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#Perl
Perl
sub show_bool { return shift() ? 'true' : 'false', "\n"; }   sub test_logic { my ($a, $b) = @_; print "a and b is ", show_bool $a && $b; print "a or b is ", show_bool $a || $b; print "not a is ", show_bool !$a; print "a xor b is ", show_bool($a xor $b); }
http://rosettacode.org/wiki/Logical_operations
Logical operations
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 |...
#Phix
Phix
function logicop(bool a, b) return {a, b, a and b, a or b, not a, a xor b, a==b, a!=b} end function printf(1," a b and or not xor ==  !=\n") for a=FALSE to TRUE do -- nb: TRUE to FALSE would need a "by -1". for b=FALSE to TRUE do printf(1,"%-5t  %-5t  %-5t  %-5t  %-5t  %...
http://rosettacode.org/wiki/Loop_over_multiple_arrays_simultaneously
Loop over multiple arrays simultaneously
Task Loop over multiple arrays   (or lists or tuples or whatever they're called in your language)   and display the   i th   element of each. Use your language's   "for each"   loop if it has one, otherwise iterate through the collection in order with some other loop. For this example, loop over the arrays: ...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
MapThread[Print, {{"a", "b", "c"}, {"A", "B", "C"}, {1, 2, 3}}];