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/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#PicoLisp
PicoLisp
(de selfRefSequence (Seed) (let L (mapcar format (chop Seed)) (make (for (Cache NIL (not (idx 'Cache L T))) (setq L (las (flip (sort (copy (link L))))) ) ) ) ) )   (let Res NIL (for Seed 1000000 (let N (length (selfRefSequence Seed)) (cond ((> ...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Nim
Nim
import sets   var setA = ["John", "Bob", "Mary", "Serena"].toHashSet var setB = ["Jim", "Mary", "John", "Bob"].toHashSet echo setA -+- setB # Symmetric difference echo setA - setB # Difference echo setB - setA # Difference
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Objective-C
Objective-C
#import <Foundation/Foundation.h>   int main(int argc, const char *argv[]) { @autoreleasepool {   NSSet* setA = [NSSet setWithObjects:@"John", @"Serena", @"Bob", @"Mary", @"Serena", nil]; NSSet* setB = [NSSet setWithObjects:@"Jim", @"Mary", @"John", @"Jim", @"Bob", nil];   // Present our initial data set ...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Lasso
Lasso
define tempconverter(temp, kind) => {   local( _temp = decimal(#temp), convertratio = 1.8, k_c = 273.15, r_f = 459.67, k,c,r,f )   match(#kind) => { case('k') #k = #_temp #c = -#k_c + #k #r = #k * #convertra...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#LIL
LIL
# Temperature conversion, in LIL func kToc k {expr $k - 273.15} func kTor k {expr $k / 5.0 * 9.0} func kTof k {expr [kTor $k] - 469.67}   write "Enter kelvin temperatures or just enter to quit: " for {set k [readline]} {![streq $k {}]} {set k [readline]} { print "Kelvin: $k" print "Celsius: [kToc $k]" ...
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#VBA
VBA
Sub Main() Dim i As Integer, c As Integer, j As Integer, strReturn() As String Dim s, n s = Split(SING_, "$") n = Split(NUMBERS_, " ") ReDim strReturn(UBound(s)) For i = LBound(s) To UBound(s) strReturn(i) = Replace(BASE_, "(X)", n(i)) For j = c To 0 Step -1 strReturn(i) = strReturn(i) ...
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#VBScript
VBScript
days = Array("first","second","third","fourth","fifth","sixth",_ "seventh","eight","ninth","tenth","eleventh","twelfth")   gifts = Array("A partridge in a pear tree","Two turtle doves","Three french hens",_ "Four calling birds","Five golden rings","Six geese a-laying","Seven swans a-swimming",_ "Eight maids a-milki...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#IDL
IDL
print,systime(0) Wed Feb 10 09:41:14 2010 print,systime(1) 1.2658237e+009
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Io
Io
Date now println
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#Python
Python
from itertools import groupby, permutations   def A036058(number): return ''.join( str(len(list(g))) + k for k,g in groupby(sorted(str(number), reverse=True)) )   def A036058_length(numberstring='0', printit=False): iterations, last_three, queue_index = 1, ([None] * 3), 0   def A036058(n...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#OCaml
OCaml
let unique lst = let f lst x = if List.mem x lst then lst else x::lst in List.rev (List.fold_left f [] lst)   let ( -| ) a b = unique (List.filter (fun v -> not (List.mem v b)) a)   let ( -|- ) a b = (b -| a) @ (a -| b)
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#ooRexx
ooRexx
a = .set~of("John", "Bob", "Mary", "Serena") b = .set~of("Jim", "Mary", "John", "Bob") -- the xor operation is a symmetric difference do item over a~xor(b) say item end
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#LiveCode
LiveCode
function convertDegrees k put k/5 * 9 into r put k - 273.15 into c put r - 459.67 into f return k,r,c,f end convertDegrees
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Lua
Lua
function convert_temp(k) local c = k - 273.15 local r = k * 1.8 local f = r - 459.67 return k, c, r, f end   print(string.format([[ Kelvin: %.2f K Celcius: %.2f °C Rankine: %.2f °R Fahrenheit: %.2f °F ]],convert_temp(21.0)))
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Vedit_macro_language
Vedit macro language
for (#1 = 1; #1 <= 12; #1++) { Num_Str(#1, 9, LEFT) IT("On the ") Call("day |@(9)") IT(" day of Christmas, my true love sent to me:") IN Call("gift |@(9)") IN } return   :day 1: IT("first") return :day 2: IT("second") return :day 3: IT("third") return :day 4: IT("fourth") return :d...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#IS-BASIC
IS-BASIC
100 PRINT TIME$
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#J
J
6!:0 '' 2008 1 23 12 52 10.341
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#q
q
ls:{raze(string 1_ deltas d,count x),'x d:where differ x} / look & say sumsay:ls desc@ / summarize & say   seeds:group desc each string til 1000000 / seeds for million integers seq:(key seeds)!30 sumsay\'key seeds / sequences for unique...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Oz
Oz
declare fun {SymDiff A B} {Union {Diff A B} {Diff B A}} end   %% implement sets in terms of lists fun {MakeSet Xs} set({Nub2 Xs nil}) end   fun {Diff set(A) set(B)} set({FoldL B List.subtract A}) end   fun {Union set(A) set(B)} set({Append A B}) end   %% -- fun {Nub2 Xs Ls} ...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Liberty_BASIC
Liberty BASIC
Do Input "Kelvin degrees (>=0): ";K Loop Until (K >= 0)   Print "K = ";K Print "C = ";(K - 273.15) Print "F = ";(K * 1.8 - 459.67) Print "R = ";(K * 1.8) End
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Maple
Maple
tempConvert := proc(k) seq(printf("%c: %.2f\n", StringTools[UpperCase](substring(i, 1)), convert(k, temperature, kelvin, i)), i in [kelvin, Celsius, Fahrenheit, Rankine]); return NULL; end proc:   tempConvert(21);
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Vim_Script
Vim Script
  let b:days=["first", "second", "third", "fourth", "fifth", "sixth", \ "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"]   let b:gifts=[ \ "And a partridge in a pear tree.", \ "Two turtle doves,", \ "Three french hens,", \ "Four calling birds,", \ "Five golden rings,", \ "Six g...
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Visual_Basic_.NET
Visual Basic .NET
Module Program Sub Main() Dim days = New String(11) {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"} Dim gifts = New String(11) { "A partridge in a pear tree", "Two turtle doves", "Three french ...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Java
Java
public class SystemTime{ public static void main(String[] args){ System.out.format("%tc%n", System.currentTimeMillis()); } }
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#JavaScript
JavaScript
console.log(new Date()) // => Sat, 28 May 2011 08:22:53 GMT console.log(Date.now()) // => 1306571005417 // Unix epoch
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#Racket
Racket
  #lang racket   (define (next s) (define v (make-vector 10 0)) (for ([c s]) (define d (- (char->integer #\9) (char->integer c))) (vector-set! v d (add1 (vector-ref v d)))) (string-append* (for/list ([x v] [i (in-range 9 -1 -1)] #:when (> x 0)) (format "~a~a" x i))))   (define (seq-of ...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#PARI.2FGP
PARI/GP
sd(u,v)={ my(r=List()); u=vecsort(u,,8); v=vecsort(v,,8); for(i=1,#u,if(!setsearch(v,u[i]),listput(r,u[i]))); for(i=1,#v,if(!setsearch(u,v[i]),listput(r,v[i]))); Vec(r) }; sd(["John", "Serena", "Bob", "Mary", "Serena"],["Jim", "Mary", "John", "Jim", "Bob"])
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
tempConvert[t_] := # -> Thread@UnitConvert[#,{"DegreesFahrenheit", "DegreesCelsius", "DegreesRankine"}]&@Quantity[N@t, "Kelvins"] tempConvert[21]
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Wren
Wren
var days = [ "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth" ]   var gifts = [ "A partridge in a pear tree.", "Two turtle doves and", "Three french hens", "Four calling birds", "Five golden rings", "Six geese a-laying", "Seven swan...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#jq
jq
$ jq -n 'now | [., todate]' [ 1437619000.970498, "2015-07-23T02:36:40Z" ]
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Jsish
Jsish
console.log(strftime());
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#Raku
Raku
my @list; my $longest = 0; my %seen;   for 1 .. 1000000 -> $m { next unless $m ~~ /0/; # seed must have a zero my $j = join '', $m.comb.sort; next if %seen{$j}:exists; # already tested a permutation %seen{$j} = ''; my @seq = converging($m); my %elems; my $count; for @seq[] -...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Pascal
Pascal
PROGRAM Symmetric_difference;   TYPE TName = (Bob, Jim, John, Mary, Serena); TList = SET OF TName;   PROCEDURE Put(txt : String; ResSet : TList); VAR I : TName;   BEGIN Write(txt); FOR I IN ResSet DO Write(I,' '); WriteLn END;   VAR ListA : TList = [John, Bob, Mary, Serena]; ListB : TList = [Jim, Mary, ...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#min
min
( ((float) (273.15 -) (9 5 / * 459.67 -) (9 5 / *)) cleave () 'cons 4 times "K $1\nC $2\nF $3\nR $4" swap % puts! ) :convert   21 convert
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#XPL0
XPL0
int Day, Gift, D, G; [Day:= [0, "first", "second", "third", "forth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"]; Gift:= [0, "A partridge in a pear tree.", "Two turtle doves, and", "Three french hens,", "Four calling birds,", "Five ...
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Yabasic
Yabasic
dim day$(12), gift$(12) for i = 1 to 12: read day$(i): next i for i = 1 to 12: read gift$(i): next i for i = 1 to 12 print "On the ", day$(i), " day of Christmas," print "My true love gave to me:" for j = i to 1 step -1: print gift$(j): next j print next i end   data "first","second","third","fourth","f...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Julia
Julia
  ts = time()   println("The system time is (in ISO 8601 format):") println(strftime("  %F %T %Z", ts))  
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Kotlin
Kotlin
// version 1.0.6   fun main(args: Array<String>) { println("%tc".format(System.currentTimeMillis())) }  
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#REXX
REXX
/*REXX pgm generates a self─referential sequence and displays sequences with max length.*/ parse arg LO HI . /*obtain optional arguments from the CL*/ if LO=='' | LO=="," then LO= 1 /*Not specified? Then use the default.*/ if HI=='' | HI=="," then HI=1000000 - 1 ...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Perl
Perl
sub symm_diff { # two lists passed in as references my %in_a = map(($_=>1), @{+shift}); my %in_b = map(($_=>1), @{+shift});   my @a = grep { !$in_b{$_} } keys %in_a; my @b = grep { !$in_a{$_} } keys %in_b;   # return A-B, B-A, A xor B as ref to lists return \@a, \...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#MiniScript
MiniScript
fromKelvin = function(temp) print temp + " degrees in Kelvin is:" Celsius = temp - 273.15 print Celsius + " degrees Celsius" Fahrenheit = round(Celsius * 9/5 + 32,2) print Fahrenheit + " degrees Fahrenheit" Rankine = Fahrenheit + 459.67 print Rankine + " degrees Rankine" end function   temp...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#MiniZinc
MiniZinc
float: kelvin;   var float: celsius; var float: fahrenheit; var float: rankine;   constraint celsius == kelvin - 273.15; constraint fahrenheit == celsius * 1.8 + 32; constraint rankine == fahrenheit + 459.67; solve satisfy;   output ["K \(kelvin)\n", "C \(celsius)\n", "F \(fahrenheit)\n", "R \(rankine)\n"];
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#Z80_Assembly
Z80 Assembly
waitChar equ &BB06 ;wait for a key press PrintChar equ &BB5A ;print accumulator to screen   org &8000   ld ix,VerseTable inc ix inc ix ld iy,SongLookup   ld b,12 ;12 verses total outerloop_song: push af ;new line ld a,13 call PrintChar ld a,10 call PrintChar pop af push bc push i...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Lambdatalk
Lambdatalk
  {date} -> 2021 02 22 07 23 12  
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Lasso
Lasso
date->format('%Q %T') date->asInteger
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#Ruby
Ruby
$cache = {} def selfReferentialSequence_cached(n, seen = []) return $cache[n] if $cache.include? n return [] if seen.include? n   digit_count = Array.new(10, 0) n.to_s.chars.collect {|char| digit_count[char.to_i] += 1} term = '' 9.downto(0).each do |d| if digit_count[d] > 0 term += digit_count[d]....
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Phix
Phix
function Union(sequence a, sequence b) for i=1 to length(a) do if not find(a[i],b) then b = append(b,a[i]) end if end for return b end function function Difference(sequence a, sequence b) sequence res = {} for i=1 to length(a) do if not find(a[i],b) and not ...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#.D0.9C.D0.9A-61.2F52
МК-61/52
П7 0 , 8 * П8 ИП7 9 * 5 / 3 2 + П9 ИП7 2 7 3 , 1 5 + П4 С/П П8 1 , 8 / БП 00 П9 3 2 - 5 * 9 / БП 00 П4 2 7 3 , 1 5 - БП 00
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#ML
ML
fun KtoC n = n - 273.15; fun KtoF n = n * 1.8 - 459.67; fun KtoR n = n * 1.8; val K = argv 0;   if K = false then println "mlite -f temcon.m <temp>" else let val K = ston K in print "Kelvin: "; println K; print "Celcius: "; println ` KtoC K; print "Fahrenheit: "; pri...
http://rosettacode.org/wiki/The_Twelve_Days_of_Christmas
The Twelve Days of Christmas
Task Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here. (You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.) Other tasks related to string operations: Metrics Array length Stri...
#zkl
zkl
gifts:= #<<< "A beer, in a tree.; Two turtlenecks; Three french toast; Four pounds of backbacon; Five golden touques; Six packs of two-four; Seven packs of smokes; Eight comic books; Nine back up singers; Ten feet of snow; Eleven hosers hosing; Twelve dozen donuts" #<<< .split(";").apply("strip");   days:=("first seco...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#LFE
LFE
  > (os:timestamp) #(1423 786308 145798)  
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Liberty_BASIC
Liberty BASIC
print time$() 'time now as string "16:21:44" print time$("seconds") 'seconds since midnight as number 32314 print time$("milliseconds") 'milliseconds since midnight as number 33221342 print time$("ms") 'milliseconds since midnight as number 33221342
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#Scala
Scala
import spire.math.SafeLong   import scala.annotation.tailrec import scala.collection.parallel.immutable.ParVector   object SelfReferentialSequence { def main(args: Array[String]): Unit = { val nums = ParVector.range(1, 1000001).map(SafeLong(_)) val seqs = nums.map{ n => val seq = genSeq(n); (n, seq, seq.lengt...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#PHP
PHP
<?php $a = array('John', 'Bob', 'Mary', 'Serena'); $b = array('Jim', 'Mary', 'John', 'Bob');   // Remove any duplicates $a = array_unique($a); $b = array_unique($b);   // Get the individual differences, using array_diff() $a_minus_b = array_diff($a, $b); $b_minus_a = array_diff($b, $a);   // Simply merge them together ...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Nanoquery
Nanoquery
% while true ... print "K ? " ... k = float(input()) ... ... println format("%g Kelvin = %g Celsius = %g Fahrenheit = %g Rankine degrees.", k, k-273.15, k*1.8-459.67, k*1.8) ... end K ? 21 21.0000 Kelvin = -252.150 Celsius = -421.870 Fahrenheit = 37.8000 Rankine degrees. K ? 222.2 222.200 Kelvin = -...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#LIL
LIL
print [system date]; print [system date +%s.%N]
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Lingo
Lingo
put time() -- "03:45"   put date() -- "01.10.2016"   put the systemdate -- date( 2016, 10, 1 )   put the systemdate.seconds -- 13950   -- milliseconds since last boot, due to higher resolution better suited for random number seeding put _system.milliseconds -- 41746442
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#Tcl
Tcl
proc nextterm n { foreach c [split $n ""] {incr t($c)} foreach c {9 8 7 6 5 4 3 2 1 0} { if {[info exist t($c)]} {append r $t($c) $c} } return $r } # Local context of lambda term is just for speed apply {limit { # Build a digit cache; this adds quite a bit of speed set done [lrepeat [set l2 [e...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Picat
Picat
import ordset.   go => A = ["John", "Serena", "Bob", "Mary", "Serena"].new_ordset(), B = ["Jim", "Mary", "John", "Jim", "Bob"].new_ordset(),   println(symmetric_difference=symmetric_difference(A,B)), println(symmetric_difference2=symmetric_difference2(A,B)),   println(subtractAB=subtract(A,B)), println(subt...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#PicoLisp
PicoLisp
(de symdiff (A B) (uniq (conc (diff A B) (diff B A))) )
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#NetRexx
NetRexx
/* NetRexx */ options replace format comments java crossref symbols   numeric digits 20   runSample(arg) return   -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* + Kelvin Celsius Fahrenheit Rankine Delisle Newton Réaumur ...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#LiveCode
LiveCode
put the system time
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Locomotive_Basic
Locomotive Basic
print time print time/300;"s since last reboot"
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#TXR
TXR
;; Syntactic sugar for calling reduce-left (defmacro reduce-with ((acc init item sequence) . body) ^(reduce-left (lambda (,acc ,item) ,*body) ,sequence ,init))    ;; Macro similar to clojure's ->> and -> (defmacro opchain (val . ops) ^[[chain ,*[mapcar [iffi consp (op cons 'op)] ops]] ,val])   ;; Reduce integer to ...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Pike
Pike
> multiset(string) A = (< "John", "Serena", "Bob", "Mary", "Bob", "Serena" >); > multiset(string) B = (< "Jim", "Mary", "Mary", "John", "Bob", "Jim" >);   > A^B; Result: (< "Bob", "Serena", "Serena", "Mary", "Jim", "Jim" >)
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Never
Never
  func KtoC(k : float) -> float { k - 273.15 } func KtoF(k : float) -> float { k * 1.8 - 459.67 } func KtoR(k : float) -> float { k * 1.8 }   func convertK(k : float) -> int { prints("K " + k + "\n"); prints("C " + KtoC(k) + "\n"); prints("F " + KtoF(k) + "\n"); prints("R " + KtoR(k) + "\n"); 0 }   ...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Logo
Logo
  to time output first first shell [date +%s] end   make "start time wait 300  ; 60ths of a second print time - :start  ; 5
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Lua
Lua
print(os.date())
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#Wren
Wren
import "/seq" for Lst import "/math" for Nums   var limit = 1e6   var selfRefSeq = Fn.new { |s| var sb = "" for (d in "9876543210") { if (s.contains(d)) { var count = s.count { |c| c == d } sb = sb + "%(count)%(d)" } } return sb }   var permute // recursive permut...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#PL.2FI
PL/I
/* PL/I *************************************************************** * 17.08.2013 Walter Pachl **********************************************************************/ *process source attributes xref; sd: Proc Options(main); Dcl a(4) Char(20) Var Init('John','Bob','Mary','Serena'); Dcl b(4) Char(20) Var Init('Jim'...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#NewLISP
NewLISP
  (define (to-celsius k) (- k 273.15) )   (define (to-fahrenheit k) (- (* k 1.8) 459.67) )   (define (to-rankine k) (* k 1.8) )   (define (kelvinConversion k) (if (number? k) (println k " kelvin is equivalent to:\n" (to-celsius k) " celsius\n" (to-fahrenheit k) " fahren...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#M2000_Interpreter
M2000 Interpreter
  print str$(now,"long time"), time$(now)  
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
Print[DateList[]] Print[AbsoluteTime[]]
http://rosettacode.org/wiki/Summarize_and_say_sequence
Summarize and say sequence
There are several ways to generate a self-referential sequence. One very common one (the Look-and-say sequence) is to start with a positive integer, then generate the next term by concatenating enumerated groups of adjacent alike digits: 0, 10, 1110, 3110, 132110, 1113122110, 311311222110 ... The terms generat...
#zkl
zkl
N:=0d1_000_001;   fcn lookAndJustSaying(seed){ // numeric String --> numeric String "9876543210".pump(String,'wrap(n){ (s:=seed.inCommon(n)) and String(s.len(),n) or "" }); } fcn sequence(seed){ // numeric string --> sequence until it repeats seq:=L(); while(not seq.holds(seed)){ seq.append(seed); see...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#PowerShell
PowerShell
$A = @( "John" "Bob" "Mary" "Serena" )   $B = @( "Jim" "Mary" "John" "Bob" )   # Full commandlet name and full parameter names Compare-Object -ReferenceObject $A -DifferenceObject $B   # Same commandlet using an alias and positional parameters Compare $A $B   # A - B C...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Nim
Nim
import rdstdin, strutils, strfmt   while true: let k = parseFloat readLineFromStdin "K ? " echo "{:g} Kelvin = {:g} Celsius = {:g} Fahrenheit = {:g} Rankine degrees".fmt( k, k - 273.15, k * 1.8 - 459.67, k * 1.8)
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#MATLAB_.2F_Octave
MATLAB / Octave
datestr(now)
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Maxima
Maxima
/* Time and date in a formatted string */ timedate(); "2012-08-27 20:26:23+10:00"   /* Time in seconds elapsed since 1900/1/1 0:0:0 */ absolute_real_time();   /* Time in seconds since Maxima was started */ elapsed_real_time(); elapsed_run_time();
http://rosettacode.org/wiki/Sum_of_elements_below_main_diagonal_of_matrix
Sum of elements below main diagonal of matrix
Task Find and display the sum of elements that are below the main diagonal of a matrix. The matrix should be a square matrix. ───   Matrix to be used:   ─── [[1,3,7,8,10], [2,4,16,14,4], [3,1,9,18,11], [12,14,17,18,20], [7,1,3,9,5]]
#11l
11l
F sumBelowDiagonal(m) V result = 0 L(i) 1 .< m.len L(j) 0 .< i result += m[i][j] R result   V m = [[ 1, 3, 7, 8, 10], [ 2, 4, 16, 14, 4], [ 3, 1, 9, 18, 11], [12, 14, 17, 18, 20], [ 7, 1, 3, 9, 5]]   print(sumBelowDiagonal(m))
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Prolog
Prolog
sym_diff :- A = ['John', 'Serena', 'Bob', 'Mary', 'Serena'], B = ['Jim', 'Mary', 'John', 'Jim', 'Bob'], format('A : ~w~n', [A]), format('B : ~w~n', [B]), list_to_set(A, SA), list_to_set(B, SB), format('set from A : ~w~n', [SA]), format('set from B : ~w~n', [SB]), subtract(SA, SB, DAB...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Objeck
Objeck
  class Temperature { function : Main(args : String[]) ~ Nil { k := System.IO.Console->ReadString()->ToFloat(); c := KelvinToCelsius(k); f := KelvinToFahrenheit(k); r := KelvinToRankine(k);   "K: {$k}"->PrintLine(); "C: {$c}"->PrintLine(); "F: {$f}"->PrintLine(); "R: {$r}"->PrintLine()...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#min
min
now datetime puts!
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Modula-2
Modula-2
  MODULE Mytime;   FROM SysClock IMPORT GetClock, DateTime; FROM STextIO IMPORT WriteString, WriteLn; FROM FormatDT IMPORT DateTimeToString;   VAR CurrentTime: DateTime; DateStr, TimeStr: ARRAY [0 .. 20] OF CHAR; BEGIN GetClock(CurrentTime); DateTimeToString(CurrentTime, DateStr, TimeStr); WriteString("...
http://rosettacode.org/wiki/Sum_of_elements_below_main_diagonal_of_matrix
Sum of elements below main diagonal of matrix
Task Find and display the sum of elements that are below the main diagonal of a matrix. The matrix should be a square matrix. ───   Matrix to be used:   ─── [[1,3,7,8,10], [2,4,16,14,4], [3,1,9,18,11], [12,14,17,18,20], [7,1,3,9,5]]
#Action.21
Action!
PROC PrintMatrix(INT ARRAY m BYTE size) BYTE x,y INT v   FOR y=0 TO size-1 DO FOR x=0 TO size-1 DO v=m(x+y*size) IF v<10 THEN Put(32) FI PrintB(v) Put(32) OD PutE() OD RETURN   INT FUNC SumBelowDiagonal(INT ARRAY m BYTE size) BYTE x,y INT sum   sum=0 FOR y=1 TO size-1...
http://rosettacode.org/wiki/Sum_of_elements_below_main_diagonal_of_matrix
Sum of elements below main diagonal of matrix
Task Find and display the sum of elements that are below the main diagonal of a matrix. The matrix should be a square matrix. ───   Matrix to be used:   ─── [[1,3,7,8,10], [2,4,16,14,4], [3,1,9,18,11], [12,14,17,18,20], [7,1,3,9,5]]
#Ada
Ada
with Ada.Text_Io; with Ada.Numerics.Generic_Real_Arrays;   procedure Sum_Below_Diagonals is   type Real is new Float;   package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (Real);   function Sum_Below_Diagonal (M : Real_Arrays.Real_Matrix) return Real with Pre => M'Length (1) = M'Length (2) is...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#PureBasic
PureBasic
Dim A.s(3) Dim B.s(3)   A(0)="John": A(1)="Bob": A(2)="Mary": A(3)="Serena" B(0)="Jim": B(1)="Mary":B(2)="John": B(3)="Bob"   For a=0 To ArraySize(A()) ; A-B For b=0 To ArraySize(B()) If A(a)=B(b) Break ElseIf b=ArraySize(B()) Debug A(a) EndIf Next b Next a   For b=0 To ArraySize(B()) ...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Objective-C
Objective-C
#import <Foundation/Foundation.h>   int main(int argc, const char * argv[]) { @autoreleasepool { if(argc > 1) { NSString *arg1 = [NSString stringWithCString:argv[1] encoding:NSUTF8StringEncoding]; // encoding shouldn't matter in this case double kelvin = [arg1 do...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Modula-3
Modula-3
MODULE MyTime EXPORTS Main;   IMPORT IO, FmtTime, Time;   BEGIN IO.Put("Current time: " & FmtTime.Long(Time.Now()) & "\n"); END MyTime.
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#MUMPS
MUMPS
SYSTIME NEW PH SET PH=$PIECE($HOROLOG,",",2) WRITE "The system time is ",PH\3600,":",PH\60#60,":",PH#60 KILL PH QUIT
http://rosettacode.org/wiki/Sum_of_elements_below_main_diagonal_of_matrix
Sum of elements below main diagonal of matrix
Task Find and display the sum of elements that are below the main diagonal of a matrix. The matrix should be a square matrix. ───   Matrix to be used:   ─── [[1,3,7,8,10], [2,4,16,14,4], [3,1,9,18,11], [12,14,17,18,20], [7,1,3,9,5]]
#ALGOL_68
ALGOL 68
BEGIN # sum the elements below the main diagonal of a matrix # # returns the sum of the elements below the main diagonal # # of m, m must be a square matrix # OP LOWERSUM = ( [,]INT m )INT: IF 1 LWB m /= 2 LWB m OR 1 UPB m /= 2 UPB m THEN # the matrix isn't sq...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Python
Python
>>> setA = {"John", "Bob", "Mary", "Serena"} >>> setB = {"Jim", "Mary", "John", "Bob"} >>> setA ^ setB # symmetric difference of A and B {'Jim', 'Serena'} >>> setA - setB # elements in A that are not in B {'Serena'} >>> setB - setA # elements in B that are not in A {'Jim'} >>> setA | setB # elements in A or B (union) {...
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#OCaml
OCaml
  let print_temp s t = print_string s; print_endline (string_of_float t);;   let kelvin_to_celsius k = k -. 273.15;;   let kelvin_to_fahrenheit k = (kelvin_to_celsius k)*. 9./.5. +. 32.00;;   let kelvin_to_rankine k = (kelvin_to_celsius k)*. 9./.5. +. 491.67;;     print_endline "Enter a temperature in Kelvin ...
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Nanoquery
Nanoquery
import Nanoquery.Util println new(Date).getTime()
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Neko
Neko
/** <doc> <h2>System time</h2> <p>Neko uses Int32 to store system date/time values. And lib C strftime style formatting for converting to string form</p> </doc> */   var date_now = $loader.loadprim("std@date_now", 0) var date_format = $loader.loadprim("std@date_format", 2)   var now = date_now() $print(now, " ", d...
http://rosettacode.org/wiki/Sum_of_elements_below_main_diagonal_of_matrix
Sum of elements below main diagonal of matrix
Task Find and display the sum of elements that are below the main diagonal of a matrix. The matrix should be a square matrix. ───   Matrix to be used:   ─── [[1,3,7,8,10], [2,4,16,14,4], [3,1,9,18,11], [12,14,17,18,20], [7,1,3,9,5]]
#ALGOL_W
ALGOL W
begin % sum the elements below the main diagonal of a matrix  %  % returns the sum of the elements below the main diagonal %  % of m, m must have bounds lb :: ub, lb :: ub  % integer procedure lowerSum ( integer array m ( *, * )  ; integer value lb, ub ...
http://rosettacode.org/wiki/Sum_of_elements_below_main_diagonal_of_matrix
Sum of elements below main diagonal of matrix
Task Find and display the sum of elements that are below the main diagonal of a matrix. The matrix should be a square matrix. ───   Matrix to be used:   ─── [[1,3,7,8,10], [2,4,16,14,4], [3,1,9,18,11], [12,14,17,18,20], [7,1,3,9,5]]
#APL
APL
sum_below_diagonal ← +/(∊⊢×(>/¨⍳∘⍴))
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#Quackery
Quackery
[ $ "rosetta/bitwisesets.qky" loadfile ] now!   ( i.e. using the Quackery code for sets at http://rosettacode.org/wiki/Set#Indexed_Bitmaps )   set{ John Bob Mary Serena }set is A ( --> { )   set{ Jim Mary John Bob }set is B ( --> { )   say "A \ B is " A B difference echoset cr   say "B \ A is " B A diff...
http://rosettacode.org/wiki/Symmetric_difference
Symmetric difference
Task Given two sets A and B, compute ( A ∖ B ) ∪ ( B ∖ A ) . {\displaystyle (A\setminus B)\cup (B\setminus A).} That is, enumerate the items that are in A or B but not both. This set is called the symmetric difference of A and B. In other words: ( A ∪ B ) ∖ ( A ∩ B ) {\displaystyle (A\cup B)\setminus (A...
#R
R
a <- c( "John", "Bob", "Mary", "Serena" ) b <- c( "Jim", "Mary", "John", "Bob" ) c(setdiff(b, a), setdiff(a, b))   a <- c("John", "Serena", "Bob", "Mary", "Serena") b <- c("Jim", "Mary", "John", "Jim", "Bob") c(setdiff(b, a), setdiff(a, b))
http://rosettacode.org/wiki/Temperature_conversion
Temperature conversion
There are quite a number of temperature scales. For this task we will concentrate on four of the perhaps best-known ones: Kelvin, Celsius, Fahrenheit, and Rankine. The Celsius and Kelvin scales have the same magnitude, but different null points. 0 degrees Celsius corresponds to 273.15 kelvin. 0 kelvin is absolute z...
#Oforth
Oforth
: kelvinToCelsius 273.15 - ; : kelvinToFahrenheit 1.8 * 459.67 - ; : kelvinToRankine 1.8 * ;   : testTemp(n) n kelvinToCelsius println n kelvinToFahrenheit println n kelvinToRankine println ;
http://rosettacode.org/wiki/System_time
System time
Task Output the system time   (any units will do as long as they are noted) either by a system command or one built into the language. The system time can be used for debugging, network information, random number seeds, or something as simple as program performance. Related task   Date format See also   Retr...
#Nemerle
Nemerle
System.Console.Write(System.DateTime.Now);