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/Idiomatically_determine_all_the_lowercase_and_uppercase_letters
Idiomatically determine all the lowercase and uppercase letters
Idiomatically determine all the lowercase and uppercase letters   (of the Latin [English] alphabet)   being used currently by a computer programming language. The method should find the letters regardless of the hardware architecture that is being used (ASCII, EBCDIC, or other). Task requirements Display the set of...
#AWK
AWK
  # syntax: GAWK -f IDIOMATICALLY_DETERMINE_ALL_THE_LOWERCASE_AND_UPPERCASE_LETTERS.AWK BEGIN { for (i=0; i<=255; i++) { c = sprintf("%c",i) if (c ~ /[[:lower:]]/) { lower_chars = lower_chars c } if (c ~ /[[:upper:]]/) { upper_chars = upper_chars c } } printf("%...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_lowercase_and_uppercase_letters
Idiomatically determine all the lowercase and uppercase letters
Idiomatically determine all the lowercase and uppercase letters   (of the Latin [English] alphabet)   being used currently by a computer programming language. The method should find the letters regardless of the hardware architecture that is being used (ASCII, EBCDIC, or other). Task requirements Display the set of...
#C
C
#include <stdio.h>   int main(int argc, char const *argv[]) { for (char c = 0x41; c < 0x5b; c ++) putchar(c); putchar('\n'); for (char c = 0x61; c < 0x7b; c ++) putchar(c); putchar('\n'); return 0; }
http://rosettacode.org/wiki/Imaginary_base_numbers
Imaginary base numbers
Imaginary base numbers are a non-standard positional numeral system which uses an imaginary number as its radix. The most common is quater-imaginary with radix 2i. The quater-imaginary numeral system was first proposed by Donald Knuth in 1955 as a submission for a high school science talent search. [Ref.] Other imagi...
#C
C
#include <math.h> #include <stdio.h> #include <string.h>   int find(char *s, char c) { for (char *i = s; *i != 0; i++) { if (*i == c) { return i - s; } } return -1; }   void reverse(char *b, char *e) { for (e--; b < e; b++, e--) { char t = *b; *b = *e; ...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
chars = Characters[FromCharacterCode[Range[0, 1114111]]]; out = Reap[Do[ If[Quiet[Length[Symbol[c]] == 0], Sow[c] ] , {c, chars} ]][[2, 1]]; Print["Possible 1st characters: ", out // Length] out = Reap[Do[ If[Quiet[Length[Symbol["a" <> c]] == 0], Sow[c] ] , {c,...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#Nim
Nim
import sequtils, strutils   echo "Allowed starting characters for identifiers:" echo toSeq(IdentStartChars).join() echo "" echo "Allowed characters in identifiers:" echo toSeq(IdentChars).join()
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#Ol
Ol
/*REXX program determines what characters are valid for REXX symbols.*/ /* copied from REXX version 2 */ Parse Version v Say v symbol_characters='' /* start with no chars */ do j=0 To 255 /* loop through all the chars.*/ c=d2c(j)...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#ooRexx
ooRexx
/*REXX program determines what characters are valid for REXX symbols.*/ /* copied from REXX version 2 */ Parse Version v Say v symbol_characters='' /* start with no chars */ do j=0 To 255 /* loop through all the chars.*/ c=d2c(j)...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#PARI.2FGP
PARI/GP
v=concat(concat([48..57],[65..90]),concat([97..122],95)); apply(Strchr,v)
http://rosettacode.org/wiki/Image_noise
Image noise
Generate a random black and white   320x240   image continuously, showing FPS (frames per second). A sample image
#Action.21
Action!
INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit   DEFINE TEXT_SIZE="40" BYTE ARRAY text(TEXT_SIZE)   CARD FUNC GetFrame() BYTE RTCLOK1=$13,RTCLOK2=$14 CARD res BYTE lsb=res,msb=res+1   lsb=RTCLOK2 msb=RTCLOK1 RETURN (res)   PROC CalcFPS(CARD frames REAL POINTER fps) BYTE PALNTSC=$D014 REAL ms,r1000   I...
http://rosettacode.org/wiki/Image_noise
Image noise
Generate a random black and white   320x240   image continuously, showing FPS (frames per second). A sample image
#Ada
Ada
with Lumen.Image;   package Noise is   function Create_Image (Width, Height : Natural) return Lumen.Image.Descriptor;   end Noise;
http://rosettacode.org/wiki/Image_convolution
Image convolution
One class of image digital filters is described by a rectangular matrix of real coefficients called kernel convoluted in a sliding window of image pixels. Usually the kernel is square K k l {\displaystyle K_{kl}} , where k, l are in the range -R,-R+1,..,R-1,R. W=2R+1 is the kernel width. The filter determine...
#Ada
Ada
type Float_Luminance is new Float;   type Float_Pixel is record R, G, B : Float_Luminance := 0.0; end record;   function "*" (Left : Float_Pixel; Right : Float_Luminance) return Float_Pixel is pragma Inline ("*"); begin return (Left.R * Right, Left.G * Right, Left.B * Right); end "*";   function "+" (Left, Rig...
http://rosettacode.org/wiki/Iterated_digits_squaring
Iterated digits squaring
If you add the square of the digits of a Natural number (an integer bigger than zero), you always end with either 1 or 89: 15 -> 26 -> 40 -> 16 -> 37 -> 58 -> 89 7 -> 49 -> 97 -> 130 -> 10 -> 1 An example in Python: >>> step = lambda x: sum(int(d) ** 2 for d in str(x)) >>> iterate = lambda x: x if x in [1, 89] else i...
#Tcl
Tcl
proc ids n { while {$n != 1 && $n != 89} { set n [tcl::mathop::+ {*}[lmap x [split $n ""] {expr {$x**2}}]] } return $n } for {set i 1} {$i <= 100000000} {incr i} { incr count [expr {[ids $i] == 89}] } puts $count
http://rosettacode.org/wiki/Index_finite_lists_of_positive_integers
Index finite lists of positive integers
It is known that the set of finite lists of positive integers is   countable. This means that there exists a subset of natural integers which can be mapped to the set of finite lists of positive integers. Task Implement such a mapping:   write a function     rank     which assigns an integer to any finite, arbi...
#Julia
Julia
using LinearAlgebra LinearAlgebra.rank(x::Vector{<:Integer}) = parse(BigInt, "1a" * join(x, 'a'), base=11) function unrank(n::Integer) s = "" while !iszero(n) ind = n % 11 + 1 n ÷= 11 s = "0123456789a"[ind:ind] * s end return parse.(Int, split(s, 'a'))[2:end] end   v = [0, 1, 2, ...
http://rosettacode.org/wiki/Index_finite_lists_of_positive_integers
Index finite lists of positive integers
It is known that the set of finite lists of positive integers is   countable. This means that there exists a subset of natural integers which can be mapped to the set of finite lists of positive integers. Task Implement such a mapping:   write a function     rank     which assigns an integer to any finite, arbi...
#Kotlin
Kotlin
// version 1.1.2   import java.math.BigInteger   /* Separates each integer in the list with an 'a' then encodes in base 11. Empty list mapped to '-1' */ fun rank(li: List<Int>) = when (li.size) { 0 -> -BigInteger.ONE else -> BigInteger(li.joinToString("a"), 11) }   fun unrank(r: BigInteger) = when (r) { ...
http://rosettacode.org/wiki/Integer_sequence
Integer sequence
Task Create a program that, when run, would display all integers from   1   to   ∞   (or any relevant implementation limit),   in sequence   (i.e.   1, 2, 3, 4, etc)   if given enough time. An example may not be able to reach arbitrarily-large numbers based on implementations limits.   For example, if integer...
#Cowgol
Cowgol
include "cowgol.coh";   var n: uint32 := 1; while n != 0 loop; print_i32(n); print_nl(); n := n + 1; end loop;
http://rosettacode.org/wiki/Integer_sequence
Integer sequence
Task Create a program that, when run, would display all integers from   1   to   ∞   (or any relevant implementation limit),   in sequence   (i.e.   1, 2, 3, 4, etc)   if given enough time. An example may not be able to reach arbitrarily-large numbers based on implementations limits.   For example, if integer...
#Crystal
Crystal
require "big"   (1.to_big_i ..).each { |i| puts i }
http://rosettacode.org/wiki/Infinity
Infinity
Task Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity.   Otherwise, return the largest possible po...
#Erlang
Erlang
  PROGRAM INFINITY   EXCEPTION PRINT("INFINITY") ESCI%=TRUE END EXCEPTION   BEGIN ESCI%=FALSE K=1 WHILE 2^K>0 DO EXIT IF ESCI% K+=1 END WHILE END PROGRAM  
http://rosettacode.org/wiki/Infinity
Infinity
Task Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity.   Otherwise, return the largest possible po...
#ERRE
ERRE
  PROGRAM INFINITY   EXCEPTION PRINT("INFINITY") ESCI%=TRUE END EXCEPTION   BEGIN ESCI%=FALSE K=1 WHILE 2^K>0 DO EXIT IF ESCI% K+=1 END WHILE END PROGRAM  
http://rosettacode.org/wiki/Infinity
Infinity
Task Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity.   Otherwise, return the largest possible po...
#Euphoria
Euphoria
constant infinity = 1E400   ? infinity -- outputs "inf"
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#Oz
Oz
class Camera end   class MobilePhone end   class CameraPhone from Camera MobilePhone end
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#Pascal
Pascal
package Camera; #functions go here... 1;
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#Perl
Perl
package Camera; #functions go here... 1;
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#Phix
Phix
  class Camra string name = "nikkon" end class class Mobile -- string name = "nokia" -- oops! string mane = "nokia" -- ok! end class class CamraPhone extends Camra,Mobile procedure show() ?{name,mane} end procedure end class CamraPhone cp = new() cp.show()
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#PicoLisp
PicoLisp
(class +Camera) (class +MobilePhone) (class +CameraPhone +MobilePhone +Camera)  
http://rosettacode.org/wiki/Increasing_gaps_between_consecutive_Niven_numbers
Increasing gaps between consecutive Niven numbers
Note:   Niven   numbers are also called   Harshad   numbers.   They are also called    multidigital   numbers. Niven numbers are positive integers which are evenly divisible by the sum of its digits   (expressed in base ten). Evenly divisible   means   divisible with no remainder. Task   find the gap (differen...
#Perl
Perl
use strict; use warnings; use List::Util 'sum';   sub comma { reverse ((reverse shift) =~ s/(.{3})/$1,/gr) =~ s/^,//r }   my ($index, $last, $gap, $count) = (0, 0, 0, 0); my $threshold = 10_000_000;   print "Gap Index of gap Starting Niven\n"; while (1) { $count++; next unless 0 == $count % sum split //, $c...
http://rosettacode.org/wiki/Increasing_gaps_between_consecutive_Niven_numbers
Increasing gaps between consecutive Niven numbers
Note:   Niven   numbers are also called   Harshad   numbers.   They are also called    multidigital   numbers. Niven numbers are positive integers which are evenly divisible by the sum of its digits   (expressed in base ten). Evenly divisible   means   divisible with no remainder. Task   find the gap (differen...
#Phix
Phix
with javascript_semantics integer n = 1, prev = 1, g, gap = 0, count = 1, sd = 1 sequence digits={1} procedure nNiven() while 1 do n += 1 for i=length(digits) to 0 by -1 do if i=0 then digits = prepend(digits,1) exit end if if dig...
http://rosettacode.org/wiki/Integer_overflow
Integer overflow
Some languages support one or more integer types of the underlying processor. This integer types have fixed size;   usually   8-bit,   16-bit,   32-bit,   or   64-bit. The integers supported by such a type can be   signed   or   unsigned. Arithmetic for machine level integers can often be done by single CPU instruct...
#Oforth
Oforth
5000000000000000000 5000000000000000000 + println 10000000000000000000 ok
http://rosettacode.org/wiki/Integer_overflow
Integer overflow
Some languages support one or more integer types of the underlying processor. This integer types have fixed size;   usually   8-bit,   16-bit,   32-bit,   or   64-bit. The integers supported by such a type can be   signed   or   unsigned. Arithmetic for machine level integers can often be done by single CPU instruct...
#PARI.2FGP
PARI/GP
Vecsmall([1]) Vecsmall([2^64])
http://rosettacode.org/wiki/Input_loop
Input loop
Input loop is part of Short Circuit's Console Program Basics selection. Task Read from a text stream either word-by-word or line-by-line until the stream runs out of data. The stream will have an unknown amount of data on it.
#Factor
Factor
"file.txt" utf8 [ [ process-line ] each-line ] with-file-reader
http://rosettacode.org/wiki/Input_loop
Input loop
Input loop is part of Short Circuit's Console Program Basics selection. Task Read from a text stream either word-by-word or line-by-line until the stream runs out of data. The stream will have an unknown amount of data on it.
#Fantom
Fantom
  class Main { public static Void main () { // example of reading by line str := "first\nsecond\nthird\nword" inputStream := str.in   inputStream.eachLine |Str line| { echo ("Line is: $line") }   // example of reading by word str = "first second third word" inputStream = st...
http://rosettacode.org/wiki/Isqrt_(integer_square_root)_of_X
Isqrt (integer square root) of X
Sometimes a function is needed to find the integer square root of   X,   where   X   can be a real non─negative number. Often   X   is actually a non─negative integer. For the purposes of this task,   X   can be an integer or a real number,   but if it simplifies things in your computer programming language,   assume...
#REXX
REXX
/*REXX program computes and displays the Isqrt (integer square root) of some integers.*/ numeric digits 200 /*insure 'nuff decimal digs for results*/ parse arg range power base . /*obtain optional arguments from the CL*/ if range=='' | range=="," then range= 0..65 ...
http://rosettacode.org/wiki/Inverted_index
Inverted index
An Inverted Index is a data structure used to create full text search. Task Given a set of text files, implement a program to create an inverted index. Also create a user interface to do a search using that inverted index which returns a list of files that contain the query term / terms. The search index can be i...
#Mathematica.2FWolfram_Language
Mathematica/Wolfram Language
si = CreateSearchIndex["ExampleData/Text", Method -> "TFIDF"]; Manipulate[Grid[sr = TextSearch[si, ToString[s]]; {FileBaseName /@ Normal[Dataset[sr][All, "ReferenceLocation"]], Column[#, Frame -> All] & /@ sr[All, "Snippet"]} // Transpose, Frame -> All], {s, "tree"}]
http://rosettacode.org/wiki/Introspection
Introspection
Task verify the version/revision of your currently running (compiler/interpreter/byte-compiler/runtime environment/whatever your language uses) and exit if it is too old. check whether the variable "bloop" exists and whether the math-function "abs()" is available and if yes compute abs(bloop). Extra credit Repor...
#Maxima
Maxima
/* Get version information */ build_info(); /* build_info("5.27.0", "2012-05-08 11:27:57", "i686-pc-mingw32", "GNU Common Lisp (GCL)", "GCL 2.6.8") */   %@lisp_version; /* "GCL 2.6.8" */   /* One can only check for user-defined objects: functions, variables, macros, ... Hence we won't check for 'abs, which is built-...
http://rosettacode.org/wiki/Introspection
Introspection
Task verify the version/revision of your currently running (compiler/interpreter/byte-compiler/runtime environment/whatever your language uses) and exit if it is too old. check whether the variable "bloop" exists and whether the math-function "abs()" is available and if yes compute abs(bloop). Extra credit Repor...
#MAXScript
MAXScript
fn computeAbsBloop bloop = ( versionNumber = maxVersion()   if versionNumber[1] < 9000 then ( print "Max version 9 required" return false )   if bloop == undefined then ( print "Bloop is undefined" return false )   try ( abs bloop ) cat...
http://rosettacode.org/wiki/Josephus_problem
Josephus problem
Josephus problem is a math puzzle with a grim description: n {\displaystyle n} prisoners are standing on a circle, sequentially numbered from 0 {\displaystyle 0} to n − 1 {\displaystyle n-1} . An executioner walks along the circle, starting from prisoner 0 {\displaystyle 0} , removing eve...
#NetRexx
NetRexx
/* NetRexx */ options replace format comments java crossref symbols nobinary   /* REXX ************************************************************** * 15.11.2012 Walter Pachl - my own solution * 16.11.2012 Walter Pachl generalized n prisoners + w killing distance * and s=number of survivors ***...
http://rosettacode.org/wiki/Interactive_programming_(repl)
Interactive programming (repl)
Many language implementations come with an interactive mode. This is a command-line interpreter that reads lines from the user and evaluates these lines as statements or expressions. An interactive mode may also be known as a command mode,   a read-eval-print loop (REPL),   or a shell. Task Show how to start this...
#Pike
Pike
$ pike Pike v7.8 release 352 running Hilfe v3.5 (Incremental Pike Frontend) > string f(string first, string second, string sep){ >> return(first + sep + sep + second); >> } > f("Rosetta","Code",":"); (1) Result: "Rosetta::Code" >
http://rosettacode.org/wiki/Interactive_programming_(repl)
Interactive programming (repl)
Many language implementations come with an interactive mode. This is a command-line interpreter that reads lines from the user and evaluates these lines as statements or expressions. An interactive mode may also be known as a command mode,   a read-eval-print loop (REPL),   or a shell. Task Show how to start this...
#PowerShell
PowerShell
Windows PowerShell Copyright (C) 2009 Microsoft Corporation. All rights reserved.   PS Home:\> function f ([string] $string1, [string] $string2, [string] $separator) { >> $string1 + $separator * 2 + $string2 >> } >> PS Home:\> f 'Rosetta' 'Code' ':' Rosetta::Code PS Home:\>
http://rosettacode.org/wiki/ISBN13_check_digit
ISBN13 check digit
Task Validate the check digit of an ISBN-13 code:   Multiply every other digit by  3.   Add these numbers and the other digits.   Take the remainder of this number after division by  10.   If it is  0,   the ISBN-13 check digit is correct. Use the following codes for testing:   978-1734314502       (good)   ...
#Ring
Ring
  load "stdlib.ring"   isbn = ["978-1734314502","978-1734314509", "978-1788399081", "978-1788399083","978-2-74839-908-0","978-2-74839-908-5","978 1 86197 876 9"]   for n = 1 to len(isbn) sum = 0 isbnStr = isbn[n] isbnStr = substr(isbnStr,"-","") isbnStr = substr(isbnStr," ","") for m = 1 to len(isbn...
http://rosettacode.org/wiki/Jaro_similarity
Jaro similarity
The Jaro distance is a measure of edit distance between two strings; its inverse, called the Jaro similarity, is a measure of two strings' similarity: the higher the value, the more similar the strings are. The score is normalized such that   0   equates to no similarities and   1   is an exact match. Definition The...
#ZX_Spectrum_Basic
ZX Spectrum Basic
10 LET a$="MARTHA": LET b$="MARHTA": PRINT a$;", ";b$;": ";: GO SUB 1000: PRINT jaro 20 LET a$="DIXON": LET b$="DICKSONX": PRINT a$;", ";b$;": ";: GO SUB 1000: PRINT jaro 30 LET a$="JELLYFISH": LET b$="SMELLYFISH": PRINT a$;", ";b$;": ";: GO SUB 1000: PRINT jaro 900 STOP 1000 REM Jaro subroutine 1010 LET s1=LEN a$: LE...
http://rosettacode.org/wiki/Increment_a_numerical_string
Increment a numerical string
Task Increment a numerical string.
#Aime
Aime
  o_text(itoa(atoi("2047") + 1)); o_byte('\n');  
http://rosettacode.org/wiki/Increment_a_numerical_string
Increment a numerical string
Task Increment a numerical string.
#ALGOL_68
ALGOL 68
STRING s := "12345"; FILE f; INT i; associate(f, s); get(f,i); i+:=1; s:=""; reset(f); put(f,i); print((s, new line))
http://rosettacode.org/wiki/Integer_comparison
Integer comparison
Basic Data Operation This is a basic data operation. It represents a fundamental action on a basic data type. You may see other such operations in the Basic Data Operations category, or: Integer Operations Arithmetic | Comparison Boolean Operations Bitwise | Logical String Operations Concatenation | Interpolation |...
#Astro
Astro
let a = input('Enter value of a: ') let b = input('Enter value of b: ')   if a < b: print 'a is less than b' elif a > b: print 'a is greater than b' elif a == b: print 'a is equal to b'
http://rosettacode.org/wiki/Include_a_file
Include a file
Task Demonstrate the language's ability to include source code from other files. See Also Compiler/Simple file inclusion pre processor
#Arturo
Arturo
; import a file do.import {file.art}   ; import another file ; from relative folder location do.import relative "another_file.art"
http://rosettacode.org/wiki/Include_a_file
Include a file
Task Demonstrate the language's ability to include source code from other files. See Also Compiler/Simple file inclusion pre processor
#AutoHotkey
AutoHotkey
  #Include FileOrDirName #IncludeAgain FileOrDirName  
http://rosettacode.org/wiki/Include_a_file
Include a file
Task Demonstrate the language's ability to include source code from other files. See Also Compiler/Simple file inclusion pre processor
#AWK
AWK
awk -f one.awk -f two.awk
http://rosettacode.org/wiki/Inheritance/Single
Inheritance/Single
This task is about derived types;   for implementation inheritance, see Polymorphism. Inheritance is an operation of type algebra that creates a new type from one or several parent types. The obtained type is called derived type. It inherits some of the properties of its parent types. Usually inherited properties...
#Haskell
Haskell
class Animal a class Animal a => Cat a class Animal a => Dog a class Dog a => Lab a class Dog a => Collie a
http://rosettacode.org/wiki/Inheritance/Single
Inheritance/Single
This task is about derived types;   for implementation inheritance, see Polymorphism. Inheritance is an operation of type algebra that creates a new type from one or several parent types. The obtained type is called derived type. It inherits some of the properties of its parent types. Usually inherited properties...
#Haxe
Haxe
class Animal { // ... }
http://rosettacode.org/wiki/Inheritance/Single
Inheritance/Single
This task is about derived types;   for implementation inheritance, see Polymorphism. Inheritance is an operation of type algebra that creates a new type from one or several parent types. The obtained type is called derived type. It inherits some of the properties of its parent types. Usually inherited properties...
#Icon_and_Unicon
Icon and Unicon
  class Animal () end   class Dog : Animal () end   class Cat : Animal () end   class Lab : Dog () end   class Collie : Dog () end  
http://rosettacode.org/wiki/Idiomatically_determine_all_the_lowercase_and_uppercase_letters
Idiomatically determine all the lowercase and uppercase letters
Idiomatically determine all the lowercase and uppercase letters   (of the Latin [English] alphabet)   being used currently by a computer programming language. The method should find the letters regardless of the hardware architecture that is being used (ASCII, EBCDIC, or other). Task requirements Display the set of...
#COBOL
COBOL
identification division. program-id. determine.   environment division. configuration section. repository. function all intrinsic.   data division. working-storage section. 01 tx pic x. 01 lower-8bit pic x(256). 01 upper-8bit pic x(256).  ...
http://rosettacode.org/wiki/Imaginary_base_numbers
Imaginary base numbers
Imaginary base numbers are a non-standard positional numeral system which uses an imaginary number as its radix. The most common is quater-imaginary with radix 2i. The quater-imaginary numeral system was first proposed by Donald Knuth in 1955 as a submission for a high school science talent search. [Ref.] Other imagi...
#C.23
C#
using System; using System.Linq; using System.Text;   namespace ImaginaryBaseNumbers { class Complex { private double real, imag;   public Complex(int r, int i) { real = r; imag = i; }   public Complex(double r, double i) { real = r; im...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#Perl
Perl
# When not using the <code>use utf8</code> pragma, any word character in the ASCII range is allowed. # the loop below returns: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz for $i (0..0x7f) { $c = chr($i); print $c if $c =~ /\w/; }   # When 'use utf8' is in force, the same holds true, but the ...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#Phix
Phix
without js -- file i/o, system_exec, \t and \r chars function run(string ident) integer fn = open("test.exw","w") printf(fn,"object %s",ident) close(fn) return system_exec("p -batch test.exw") end function function check(integer lo, hi) string ok1 = "", ok2 = "" integer ng1 = 0, ng2 = 0 fo...
http://rosettacode.org/wiki/Image_noise
Image noise
Generate a random black and white   320x240   image continuously, showing FPS (frames per second). A sample image
#Axe
Axe
.Enable 15 MHz full speed mode Full .Disable memory access delays (adds 1 FPS) Fullʳ   .Flush key presses While getKey(0) End   .Setup 0→F 0→N Fix 5 fnInt(FPS,6)   Repeat getKey(0) NOISE() F++ .Reset the FPS counter before it overflows F>606?0→F→N Text(0,0,F*108/N▶Dec) DispGraph End   .Clean up LnRegʳ Fix 4 Retur...
http://rosettacode.org/wiki/Image_noise
Image noise
Generate a random black and white   320x240   image continuously, showing FPS (frames per second). A sample image
#BBC_BASIC
BBC BASIC
dx% = 320 dy% = 240 images% = 100000 VDU 23,22,dx%;dy%;8,8,16,0   REM Create a block of random data in memory: DIM random% dx%*dy%+images% FOR R% = random% TO random%+dx%*dy%+images%  ?R% = RND(256)-1 NEXT   REM Create a BMP file structure: DIM bmpfile{...
http://rosettacode.org/wiki/Image_convolution
Image convolution
One class of image digital filters is described by a rectangular matrix of real coefficients called kernel convoluted in a sliding window of image pixels. Usually the kernel is square K k l {\displaystyle K_{kl}} , where k, l are in the range -R,-R+1,..,R-1,R. W=2R+1 is the kernel width. The filter determine...
#BBC_BASIC
BBC BASIC
Width% = 200 Height% = 200   DIM out&(Width%-1, Height%-1, 2)   VDU 23,22,Width%;Height%;8,16,16,128 *DISPLAY Lena OFF   DIM filter%(2, 2) filter%() = -1, -1, -1, -1, 12, -1, -1, -1, -1   REM Do the convolution: FOR Y% = 1 TO Height%-2 FOR X% = 1 TO Wi...
http://rosettacode.org/wiki/Image_convolution
Image convolution
One class of image digital filters is described by a rectangular matrix of real coefficients called kernel convoluted in a sliding window of image pixels. Usually the kernel is square K k l {\displaystyle K_{kl}} , where k, l are in the range -R,-R+1,..,R-1,R. W=2R+1 is the kernel width. The filter determine...
#C
C
image filter(image img, double *K, int Ks, double, double);
http://rosettacode.org/wiki/Iterated_digits_squaring
Iterated digits squaring
If you add the square of the digits of a Natural number (an integer bigger than zero), you always end with either 1 or 89: 15 -> 26 -> 40 -> 16 -> 37 -> 58 -> 89 7 -> 49 -> 97 -> 130 -> 10 -> 1 An example in Python: >>> step = lambda x: sum(int(d) ** 2 for d in str(x)) >>> iterate = lambda x: x if x in [1, 89] else i...
#VBScript
VBScript
  start_time = Now cnt = 0 For i = 1 To 100000000 n = i sum = 0 Do Until n = 1 Or n = 89 For j = 1 To Len(n) sum = sum + (CLng(Mid(n,j,1))^2) Next n = sum sum = 0 Loop If n = 89 Then cnt = cnt + 1 End If Next end_time = Now   WScript.Echo "Elapse Time: " & DateDiff("s",start_time,end_time) &_ vbCr...
http://rosettacode.org/wiki/Iterated_digits_squaring
Iterated digits squaring
If you add the square of the digits of a Natural number (an integer bigger than zero), you always end with either 1 or 89: 15 -> 26 -> 40 -> 16 -> 37 -> 58 -> 89 7 -> 49 -> 97 -> 130 -> 10 -> 1 An example in Python: >>> step = lambda x: sum(int(d) ** 2 for d in str(x)) >>> iterate = lambda x: x if x in [1, 89] else i...
#Wren
Wren
var endsWith89 = Fn.new { |n| var digit = 0 var sum = 0 while (true) { while (n > 0) { digit = n % 10 sum = sum + digit*digit n = (n/10).floor } if (sum == 89) return true if (sum == 1) return false n = sum sum = 0 } }  ...
http://rosettacode.org/wiki/Index_finite_lists_of_positive_integers
Index finite lists of positive integers
It is known that the set of finite lists of positive integers is   countable. This means that there exists a subset of natural integers which can be mapped to the set of finite lists of positive integers. Task Implement such a mapping:   write a function     rank     which assigns an integer to any finite, arbi...
#Mathematica_.2F_Wolfram_Language
Mathematica / Wolfram Language
ClearAll[Rank,Unrank] Rank[x_List]:=FromDigits[Catenate[Riffle[IntegerDigits/@x,{{15}},{1,-1,2}]],16] Unrank[n_Integer]:=FromDigits/@SequenceSplit[IntegerDigits[n,16],{15}] Rank[{0,1,2,3,10,100,987654321,0}] Unrank[%] First@*Unrank@*Rank@*List /@ Range[0, 20]
http://rosettacode.org/wiki/Index_finite_lists_of_positive_integers
Index finite lists of positive integers
It is known that the set of finite lists of positive integers is   countable. This means that there exists a subset of natural integers which can be mapped to the set of finite lists of positive integers. Task Implement such a mapping:   write a function     rank     which assigns an integer to any finite, arbi...
#Nim
Nim
import strformat, strutils import bignum   func rank(list: openArray[uint]): Int = result = newInt(0) for n in list: result = result shl (n + 1) result = result.setBit(n)   func unrank(n: Int): seq[uint] = var m = n.clone var a = if m.isZero: 0u else: m.bitLen.uint while a > 0: m = m.clearBit(a - ...
http://rosettacode.org/wiki/Index_finite_lists_of_positive_integers
Index finite lists of positive integers
It is known that the set of finite lists of positive integers is   countable. This means that there exists a subset of natural integers which can be mapped to the set of finite lists of positive integers. Task Implement such a mapping:   write a function     rank     which assigns an integer to any finite, arbi...
#Perl
Perl
use bigint; use ntheory qw(fromdigits todigitstring); use feature 'say';   sub rank { join '', fromdigits(join('a',@_), 11) } sub unrank { split 'a', todigitstring(@_[0], 11) }   say join ' ', @n = qw<12 11 0 7 9 15 15 5 7 13 5 5>; say $n = rank(@n); say join ' ', unrank $n;
http://rosettacode.org/wiki/Integer_sequence
Integer sequence
Task Create a program that, when run, would display all integers from   1   to   ∞   (or any relevant implementation limit),   in sequence   (i.e.   1, 2, 3, 4, etc)   if given enough time. An example may not be able to reach arbitrarily-large numbers based on implementations limits.   For example, if integer...
#D
D
import std.stdio, std.bigint;   void main() { BigInt i; while (true) writeln(++i); }
http://rosettacode.org/wiki/Integer_sequence
Integer sequence
Task Create a program that, when run, would display all integers from   1   to   ∞   (or any relevant implementation limit),   in sequence   (i.e.   1, 2, 3, 4, etc)   if given enough time. An example may not be able to reach arbitrarily-large numbers based on implementations limits.   For example, if integer...
#Dc
Dc
1[p1+lpx]dspx
http://rosettacode.org/wiki/Infinity
Infinity
Task Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity.   Otherwise, return the largest possible po...
#F.23
F#
  printfn "%f" (1.0/0.0)  
http://rosettacode.org/wiki/Infinity
Infinity
Task Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity.   Otherwise, return the largest possible po...
#Factor
Factor
1/0.
http://rosettacode.org/wiki/Infinity
Infinity
Task Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity.   Otherwise, return the largest possible po...
#Fantom
Fantom
  class Main { static Float getInfinity () { Float.posInf } public static Void main () { echo (getInfinity ()) } }  
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#Pop11
Pop11
;;; load object support lib objectclass;   define :class Camera;  ;;; slots go here enddefine;   define :class MobilePhone;  ;;; slots go here enddefine;   define :class CameraPhone is Camera, MobilePhone;  ;;; extra slots go here enddefine;   ;;; methods go here
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#PowerShell
PowerShell
  class Camera {} class MobilePhone {} class CameraPhone : Camera, MobilePhone {}  
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#PureBasic
PureBasic
Class Camera EndClass   Class Mobil EndClass   Class CameraMobile Extends Camera Extends Mobil EndClass
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#Python
Python
class Camera: pass #functions go here...
http://rosettacode.org/wiki/Inheritance/Multiple
Inheritance/Multiple
Multiple inheritance allows to specify that one class is a subclass of several other classes. Some languages allow multiple inheritance for arbitrary classes,   others restrict it to interfaces,   some don't allow it at all. Task Write two classes (or interfaces) Camera and MobilePhone,   then write a class Camer...
#Racket
Racket
#lang racket   (define camera<%> (interface ())) (define mobile-phone<%> (interface ()))   (define camera-phone% (class* object% (camera<%> mobile-phone<%>) (super-new)  ;; implement methods here ))
http://rosettacode.org/wiki/Increasing_gaps_between_consecutive_Niven_numbers
Increasing gaps between consecutive Niven numbers
Note:   Niven   numbers are also called   Harshad   numbers.   They are also called    multidigital   numbers. Niven numbers are positive integers which are evenly divisible by the sum of its digits   (expressed in base ten). Evenly divisible   means   divisible with no remainder. Task   find the gap (differen...
#Python
Python
  """   Python implementation of   http://rosettacode.org/wiki/Increasing_gaps_between_consecutive_Niven_numbers   """   # based on C example   # Returns the sum of the digits of n given the # sum of the digits of n - 1 def digit_sum(n, sum): sum += 1 while n > 0 and n % 10 == 0: sum -= 9 n /= 1...
http://rosettacode.org/wiki/Increasing_gaps_between_consecutive_Niven_numbers
Increasing gaps between consecutive Niven numbers
Note:   Niven   numbers are also called   Harshad   numbers.   They are also called    multidigital   numbers. Niven numbers are positive integers which are evenly divisible by the sum of its digits   (expressed in base ten). Evenly divisible   means   divisible with no remainder. Task   find the gap (differen...
#Raku
Raku
use Lingua::EN::Numbers;   unit sub MAIN (Int $threshold = 10000000);   my int $index = 0; my int $last = 0; my int $gap = 0;   say 'Gap Index of gap Starting Niven';   for 1..* -> \count { next unless count %% sum count.comb; if (my \diff = count - $last) > $gap { $gap = diff; printf "%3...
http://rosettacode.org/wiki/Integer_overflow
Integer overflow
Some languages support one or more integer types of the underlying processor. This integer types have fixed size;   usually   8-bit,   16-bit,   32-bit,   or   64-bit. The integers supported by such a type can be   signed   or   unsigned. Arithmetic for machine level integers can often be done by single CPU instruct...
#Perl
Perl
#include <stdio.h>
http://rosettacode.org/wiki/Integer_overflow
Integer overflow
Some languages support one or more integer types of the underlying processor. This integer types have fixed size;   usually   8-bit,   16-bit,   32-bit,   or   64-bit. The integers supported by such a type can be   signed   or   unsigned. Arithmetic for machine level integers can often be done by single CPU instruct...
#Phix
Phix
integer i = 1000000000 + 1000000000
http://rosettacode.org/wiki/Input_loop
Input loop
Input loop is part of Short Circuit's Console Program Basics selection. Task Read from a text stream either word-by-word or line-by-line until the stream runs out of data. The stream will have an unknown amount of data on it.
#Forth
Forth
4096 constant max-line : read-lines begin stdin pad max-line read-line throw while pad swap \ addr len is the line of data, excluding newline 2drop repeat ;
http://rosettacode.org/wiki/Input_loop
Input loop
Input loop is part of Short Circuit's Console Program Basics selection. Task Read from a text stream either word-by-word or line-by-line until the stream runs out of data. The stream will have an unknown amount of data on it.
#Fortran
Fortran
program BasicInputLoop   implicit none   integer, parameter :: in = 50, & linelen = 1000 integer :: ecode character(len=linelen) :: l   open(in, file="afile.txt", action="read", status="old", iostat=ecode) if ( ecode == 0 ) then do read...
http://rosettacode.org/wiki/Isqrt_(integer_square_root)_of_X
Isqrt (integer square root) of X
Sometimes a function is needed to find the integer square root of   X,   where   X   can be a real non─negative number. Often   X   is actually a non─negative integer. For the purposes of this task,   X   can be an integer or a real number,   but if it simplifies things in your computer programming language,   assume...
#Ruby
Ruby
module Commatize refine Integer do def commatize self.to_s.gsub( /(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/, "\\1,\\2") end end end   using Commatize def isqrt(x) q, r = 1, 0 while (q <= x) do q <<= 2 end while (q > 1) do q >>= 2; t = x-r-q; r >>= 1 if (t >= 0) then x, r = t, r+q...
http://rosettacode.org/wiki/Inverted_index
Inverted index
An Inverted Index is a data structure used to create full text search. Task Given a set of text files, implement a program to create an inverted index. Also create a user interface to do a search using that inverted index which returns a list of files that contain the query term / terms. The search index can be i...
#Nim
Nim
import os, strformat, strutils, tables   type   WordRef = tuple[docnum, linenum: int]   InvertedIndex = object docs: seq[string] index: Table[string, seq[WordRef]]   SearchResult = object total: int refs: seq[tuple[docname: string; linenums: seq[int]]]   IndexingError = object of CatchableError ...
http://rosettacode.org/wiki/Introspection
Introspection
Task verify the version/revision of your currently running (compiler/interpreter/byte-compiler/runtime environment/whatever your language uses) and exit if it is too old. check whether the variable "bloop" exists and whether the math-function "abs()" is available and if yes compute abs(bloop). Extra credit Repor...
#NetRexx
NetRexx
/* NetRexx */ options replace format comments java crossref symbols binary   runSample(arg) return   -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method runSample(arg) private static parse arg minVersion . if minVersion = '' then minVersion = 2.0 parse version lang ver bdate ...
http://rosettacode.org/wiki/Introspection
Introspection
Task verify the version/revision of your currently running (compiler/interpreter/byte-compiler/runtime environment/whatever your language uses) and exit if it is too old. check whether the variable "bloop" exists and whether the math-function "abs()" is available and if yes compute abs(bloop). Extra credit Repor...
#Nim
Nim
when NimVersion < "1.2": error "This compiler is too old" # Error at compile time.   assert NimVersion >= "1.4", "This compiler is too old." # Assertion defect at runtime.   var bloop = -12   when compiles abs(bloop): echo abs(bloop)
http://rosettacode.org/wiki/Josephus_problem
Josephus problem
Josephus problem is a math puzzle with a grim description: n {\displaystyle n} prisoners are standing on a circle, sequentially numbered from 0 {\displaystyle 0} to n − 1 {\displaystyle n-1} . An executioner walks along the circle, starting from prisoner 0 {\displaystyle 0} , removing eve...
#Nim
Nim
import sequtils, strutils, sugar   proc j(n, k: int): string = var p = toSeq(0 ..< n) i = 0 s = newSeq[int]()   while p.len > 0: i = (i + k - 1) mod p.len s.add p[i] system.delete(p, i)   result = "Prisoner killing order: " result.add s.map((x: int) => $x).join(", ") result.add ".\nSur...
http://rosettacode.org/wiki/Interactive_programming_(repl)
Interactive programming (repl)
Many language implementations come with an interactive mode. This is a command-line interpreter that reads lines from the user and evaluates these lines as statements or expressions. An interactive mode may also be known as a command mode,   a read-eval-print loop (REPL),   or a shell. Task Show how to start this...
#Prolog
Prolog
% library(win_menu) compiled into win_menu 0.00 sec, 12,872 bytes % library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 2,404 bytes % The graphical front-end will be used for subsequent tracing % c:/users/joel-seven/appdata/roaming/swi-prolog/pl.ini compiled 0.13 sec, 876,172 bytes XPCE 6.6.66, July 2009 for Win32...
http://rosettacode.org/wiki/Interactive_programming_(repl)
Interactive programming (repl)
Many language implementations come with an interactive mode. This is a command-line interpreter that reads lines from the user and evaluates these lines as statements or expressions. An interactive mode may also be known as a command mode,   a read-eval-print loop (REPL),   or a shell. Task Show how to start this...
#Python
Python
python Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> def f(string1, string2, separator): return separator.join([string1, '', string2])   >>> f('Rosetta', 'Code', ':') 'Rosetta::Code' >>>
http://rosettacode.org/wiki/ISBN13_check_digit
ISBN13 check digit
Task Validate the check digit of an ISBN-13 code:   Multiply every other digit by  3.   Add these numbers and the other digits.   Take the remainder of this number after division by  10.   If it is  0,   the ISBN-13 check digit is correct. Use the following codes for testing:   978-1734314502       (good)   ...
#Ruby
Ruby
def validISBN13?(str) cleaned = str.delete("^0-9").chars return false unless cleaned.size == 13 cleaned.each_slice(2).sum{|d1, d2| d1.to_i + 3*d2.to_i }.remainder(10) == 0 end   isbns = ["978-1734314502", "978-1734314509", "978-1788399081", "978-1788399083"] isbns.each{|isbn| puts "#{isbn}: #{validISBN13?(isbn)}"...
http://rosettacode.org/wiki/Increment_a_numerical_string
Increment a numerical string
Task Increment a numerical string.
#ALGOL_W
ALGOL W
begin  % returns a string representing the number in s incremented  %  % As strings are fixed length, the significant length of s must %  % be specified in length  %  % s must contain an unsigned integer  %  % If the string is invalid or ...
http://rosettacode.org/wiki/Increment_a_numerical_string
Increment a numerical string
Task Increment a numerical string.
#Apex
Apex
  string count = '12345'; count = String.valueOf(integer.valueOf(count)+1); system.debug('Incremental Value : '+count);  
http://rosettacode.org/wiki/Integer_comparison
Integer comparison
Basic Data Operation This is a basic data operation. It represents a fundamental action on a basic data type. You may see other such operations in the Basic Data Operations category, or: Integer Operations Arithmetic | Comparison Boolean Operations Bitwise | Logical String Operations Concatenation | Interpolation |...
#AutoHotkey
AutoHotkey
Gui, Add, Edit Gui, Add, UpDown, vVar1 Gui, Add, Edit Gui, Add, UpDown, vVar2 Gui, Add, Button, Default, Submit Gui, Show Return   ButtonSubmit: Gui, Submit, NoHide If (Var1 = Var2) MsgBox, % Var1 "=" Var2 Else If (Var1 < Var2) MsgBox, % Var1 "<" Var2 Else If (Var1 > Var2) MsgBox, % Var1 ">" Var2 Re...
http://rosettacode.org/wiki/Include_a_file
Include a file
Task Demonstrate the language's ability to include source code from other files. See Also Compiler/Simple file inclusion pre processor
#Axe
Axe
prgmOTHER
http://rosettacode.org/wiki/Include_a_file
Include a file
Task Demonstrate the language's ability to include source code from other files. See Also Compiler/Simple file inclusion pre processor
#BaCon
BaCon
other = 42
http://rosettacode.org/wiki/Include_a_file
Include a file
Task Demonstrate the language's ability to include source code from other files. See Also Compiler/Simple file inclusion pre processor
#BASIC
BASIC
REM $INCLUDE: 'file.bi' '$INCLUDE: 'file.bi'
http://rosettacode.org/wiki/Inheritance/Single
Inheritance/Single
This task is about derived types;   for implementation inheritance, see Polymorphism. Inheritance is an operation of type algebra that creates a new type from one or several parent types. The obtained type is called derived type. It inherits some of the properties of its parent types. Usually inherited properties...
#Inform_7
Inform 7
An animal is a kind of thing. A cat is a kind of animal. A dog is a kind of animal. A collie is a kind of dog. A lab is a kind of dog.
http://rosettacode.org/wiki/Inheritance/Single
Inheritance/Single
This task is about derived types;   for implementation inheritance, see Polymorphism. Inheritance is an operation of type algebra that creates a new type from one or several parent types. The obtained type is called derived type. It inherits some of the properties of its parent types. Usually inherited properties...
#Io
Io
Animal := Object clone Cat := Animal clone Dog := Animal clone Collie := Dog clone Lab := Dog clone
http://rosettacode.org/wiki/Inheritance/Single
Inheritance/Single
This task is about derived types;   for implementation inheritance, see Polymorphism. Inheritance is an operation of type algebra that creates a new type from one or several parent types. The obtained type is called derived type. It inherits some of the properties of its parent types. Usually inherited properties...
#J
J
coclass 'Animal'
http://rosettacode.org/wiki/Idiomatically_determine_all_the_lowercase_and_uppercase_letters
Idiomatically determine all the lowercase and uppercase letters
Idiomatically determine all the lowercase and uppercase letters   (of the Latin [English] alphabet)   being used currently by a computer programming language. The method should find the letters regardless of the hardware architecture that is being used (ASCII, EBCDIC, or other). Task requirements Display the set of...
#Common_Lisp
Common Lisp
  (flet ((do-case (converter) ;; A = 10, B = 11, ... Z = 35 (loop for radix from 10 to 35 for char = (funcall converter (digit-char radix 36)) do (format t "~&~8D #\\~24A ~S" ;; The codes and names vary across systems (char-code c...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_lowercase_and_uppercase_letters
Idiomatically determine all the lowercase and uppercase letters
Idiomatically determine all the lowercase and uppercase letters   (of the Latin [English] alphabet)   being used currently by a computer programming language. The method should find the letters regardless of the hardware architecture that is being used (ASCII, EBCDIC, or other). Task requirements Display the set of...
#Delphi
Delphi
  program Idiomatically_determine_all_the_lowercase_and_uppercase_letters;   {$APPTYPE CONSOLE}   uses System.SysUtils, System.Character;   begin var count := 0; Write('Upper case: '); for var i := 0 to $10FFFF do if char(i).IsUpper then begin write(char(i)); inc(count); if count >= ...
http://rosettacode.org/wiki/Imaginary_base_numbers
Imaginary base numbers
Imaginary base numbers are a non-standard positional numeral system which uses an imaginary number as its radix. The most common is quater-imaginary with radix 2i. The quater-imaginary numeral system was first proposed by Donald Knuth in 1955 as a submission for a high school science talent search. [Ref.] Other imagi...
#C.2B.2B
C++
#include <algorithm> #include <complex> #include <iomanip> #include <iostream>   std::complex<double> inv(const std::complex<double>& c) { double denom = c.real() * c.real() + c.imag() * c.imag(); return std::complex<double>(c.real() / denom, -c.imag() / denom); }   class QuaterImaginary { public: QuaterIma...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#Python
Python
[ $ "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrS" $ QsTtUuVvWwXxYyZz()[]{}<>~=+-*/^\|_.,:;?!'"`%@&#$Q join ] constant is tokenchars ( --> $ )   ( The first non-whitespace character after the word $ (pronounced "string") is deemed to be the delimiter for the string that...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#Quackery
Quackery
[ $ "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrS" $ QsTtUuVvWwXxYyZz()[]{}<>~=+-*/^\|_.,:;?!'"`%@&#$Q join ] constant is tokenchars ( --> $ )   ( The first non-whitespace character after the word $ (pronounced "string") is deemed to be the delimiter for the string that...
http://rosettacode.org/wiki/Idiomatically_determine_all_the_characters_that_can_be_used_for_symbols
Idiomatically determine all the characters that can be used for symbols
Idiomatically determine all the characters that can be used for symbols. The word symbols is meant things like names of variables, procedures (i.e., named fragments of programs, functions, subroutines, routines), statement labels, events or conditions, and in general, anything a computer programmer can choose to name, ...
#Racket
Racket
#lang racket ;; Symbols that don't need to be specially quoted: (printf "~s~%" '(a a-z 3rd ...---... .hidden-files-look-like-this))   ;; Symbols that do need to be specially quoted: (define bar-sym-list `(|3| |i have a space| |i've got a quote in me| |i'm not a "dot on my own", but my neighbour is!| |...