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/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Racket | Racket |
#lang racket
(require net/uri-codec)
(uri-decode "http%3A%2F%2Ffoo%20bar%2F")
|
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Raku | Raku | my @urls = < http%3A%2F%2Ffoo%20bar%2F
google.com/search?q=%60Abdu%27l-Bah%C3%A1 >;
say .subst( :g,
/ [ '%' ( <:hexdigit> ** 2 ) ]+ / ,
{ Blob.new((:16(~$_) for $0)).decode }
) for @urls; |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Metafont | Metafont | string s;
message "write a string: ";
s := readstring;
message s;
message "write a number now: ";
b := scantokens readstring;
if b = 750:
message "You've got it!"
else:
message "Sorry..."
fi;
end |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #min | min | "Enter a string" ask
"Enter an integer" ask int |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Run_BASIC | Run BASIC | html "<TABLE BORDER=1 BGCOLOR=silver>
<TR><TD colspan=2>Please input a string and a number</TD></TR>
<TR><TD align=right>String</TD><TD><input type=text name=str size=18></TD></TR>
<TR><TD align=right>Number</TD><TD><input type=number name=num size=18 value=75000></TD></TR>
<TR><TD colspan=2 align=center>"
butt... |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Scala | Scala | import swing.Dialog.{Message, showInput}
import scala.swing.Swing
object UserInput extends App {
def responce = showInput(null,
"Complete the sentence:\n\"Green eggs and...\"",
"Customized Dialog",
Message.Plain,
Swing.EmptyIcon,
Nil, "ham")
println(responce)
} |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #Rust | Rust | const INPUT: &str = "http://foo bar/";
const MAX_CHAR_VAL: u32 = std::char::MAX as u32;
fn main() {
let mut buff = [0; 4];
println!("{}", INPUT.chars()
.map(|ch| {
match ch as u32 {
0 ..= 47 | 58 ..= 64 | 91 ..= 96 | 123 ..= MAX_CHAR_VAL => {
ch.encode_u... |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #Scala | Scala | import java.net.{URLDecoder, URLEncoder}
import scala.compat.Platform.currentTime
object UrlCoded extends App {
val original = """http://foo bar/"""
val encoded: String = URLEncoder.encode(original, "UTF-8")
assert(encoded == "http%3A%2F%2Ffoo+bar%2F", s"Original: $original not properly encoded: $encoded")
... |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #OxygenBasic | OxygenBasic |
'WAYS OF DECLARING VARIABLES
'AND ASSIGNING VALUES
var int a,b,c,d
int a=1,b=2,c=3,d=4
dim int a=1,b=2, c=3, d=4
dim as int a=1,b=2, c=3, d=4
dim a=1,b=2, c=3, d=4 as int
print c '3
'CREATING ARRAY VARIABLES
int array[100]
dim int a={10,20,30,40} 'implicit array
print a[3] '30
'COMMONLY USED TYPES:
'byte word int... |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Oz | Oz | declare
Var %% new variable Var, initially free
{Show Var}
Var = 42 %% now Var has the value 42
{Show Var}
Var = 42 %% the same value is assigned again: ok
Var = 43 %% a different value is assigned: exception |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #Maple | Maple | with(LinearAlgebra):
A := Vector([3,4,5]):
B := Vector([4,3,5]):
C := Vector([-5,-12,-13]):
>>>A.B;
49
>>>CrossProduct(A,B);
Vector([5, 5, -7])
>>>A.(CrossProduct(B,C));
6
>>>CrossProduct(A,CrossProduct(B,C));
Vector([-267, 204, -3]) |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Red | Red | >> dehex "http%3A%2F%2Ffoo%20bar%2F"
== "http://foo bar/"
>> dehex "google.com/search?q=%60Abdu%27l-Bah%C3%A1"
== "google.com/search?q=`Abdu'l-Bahá" |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Retro | Retro | create buffer 32000 allot
{{
create bit 5 allot
: extract ( $c-$a ) drop @+ bit ! @+ bit 1+ ! bit ;
: render ( $c-$n )
dup '+ = [ drop 32 ] ifTrue
dup 13 = [ drop 32 ] ifTrue
dup 10 = [ drop 32 ] ifTrue
dup '% = [ extract hex toNumber decimal ] ifTrue ;
: <decode> ( $-$ ) repeat @+ 0; ren... |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Mirah | Mirah | s = System.console.readLine()
puts s |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #mIRC_Scripting_Language | mIRC Scripting Language | alias askmesomething {
echo -a You answered: $input(What's your name?, e)
} |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Scratch | Scratch | var gtk2 = require('Gtk2') -> init;
var gui = %s'Gtk2::Builder'.new;
gui.add_from_string(DATA.slurp);
func clicked_ok(*_) {
var entry = gui.get_object('entry1');
var text = entry.get_text;
var spinner = gui.get_object('spinbutton1');
var number = spinner.get_text;
say "string: #{text}";
... |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #Seed7 | Seed7 | $ include "seed7_05.s7i";
include "encoding.s7i";
const proc: main is func
begin
writeln(toPercentEncoded("http://foo bar/"));
writeln(toUrlEncoded("http://foo bar/"));
end func; |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #Sidef | Sidef | func urlencode(str) {
str.gsub!(%r"([^-A-Za-z0-9_.!~*'() ])", {|a| "%%%02X" % a.ord});
str.gsub!(' ', '+');
return str;
}
say urlencode('http://foo bar/'); |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #Tcl | Tcl | # Encode all except "unreserved" characters; use UTF-8 for extended chars.
# See http://tools.ietf.org/html/rfc3986 §2.4 and §2.5
proc urlEncode {str} {
set uStr [encoding convertto utf-8 $str]
set chRE {[^-A-Za-z0-9._~\n]}; # Newline is special case!
set replacement {%[format "%02X" [scan "\\\0" "%c"]]}
... |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #PARI.2FGP | PARI/GP | 'x |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Pascal | Pascal | sub dofruit {
$fruit='apple';
}
dofruit;
print "The fruit is $fruit"; |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | a={3,4,5};
b={4,3,5};
c={-5,-12,-13};
a.b
Cross[a,b]
a.Cross[b,c]
Cross[a,Cross[b,c]] |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #REXX | REXX | /* Rexx */
Do
X = 0
url. = ''
X = X + 1; url.0 = X; url.X = 'http%3A%2F%2Ffoo%20bar%2F'
X = X + 1; url.0 = X; url.X = 'mailto%3A%22Ivan%20Aim%22%20%3Civan%2Eaim%40email%2Ecom%3E'
X = X + 1; url.0 = X; url.X = '%6D%61%69%6C%74%6F%3A%22%49%72%6D%61%20%55%73%65%72%22%20%3C%69%72%6D%61%2E%75%73%65%72%40%6D%61%6... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Ruby | Ruby | require 'cgi'
puts CGI.unescape("http%3A%2F%2Ffoo%20bar%2F")
# => "http://foo bar/" |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Modula-3 | Modula-3 | MODULE Input EXPORTS Main;
IMPORT IO, Fmt;
VAR string: TEXT;
number: INTEGER;
BEGIN
IO.Put("Enter a string: ");
string := IO.GetLine();
IO.Put("Enter a number: ");
number := IO.GetInt();
IO.Put("You entered: " & string & " and " & Fmt.Int(number) & "\n");
END Input. |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #MUMPS | MUMPS | TXTINP
NEW S,N
WRITE "Enter a string: "
READ S,!
WRITE "Enter the number 75000: "
READ N,!
KILL S,N
QUIT |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Sidef | Sidef | var gtk2 = require('Gtk2') -> init;
var gui = %s'Gtk2::Builder'.new;
gui.add_from_string(DATA.slurp);
func clicked_ok(*_) {
var entry = gui.get_object('entry1');
var text = entry.get_text;
var spinner = gui.get_object('spinbutton1');
var number = spinner.get_text;
say "string: #{text}";
... |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #TUSCRIPT | TUSCRIPT |
$$ MODE TUSCRIPT
text="http://foo bar/"
BUILD S_TABLE spez_char="::>/:</::<%:"
spez_char=STRINGS (text,spez_char)
LOOP/CLEAR c=spez_char
c=ENCODE(c,hex),c=concat("%",c),spez_char=APPEND(spez_char,c)
ENDLOOP
url_encoded=SUBSTITUTE(text,spez_char,0,0,spez_char)
print "text: ", text
PRINT "encoded: ", url_encoded
|
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #UNIX_Shell | UNIX Shell | function urlencode
{
typeset decoded=$1 encoded= rest= c=
typeset rest2= bug='rest2=${rest}'
if [[ -z ${BASH_VERSION} ]]; then
# bug /usr/bin/sh HP-UX 11.00
typeset _decoded='xyz%26xyz'
rest="${_decoded#?}"
c="${_decoded%%${rest}}"
if (( ${#c} != 1 )); then
typeset qm='????????????????????????????????... |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Perl | Perl | sub dofruit {
$fruit='apple';
}
dofruit;
print "The fruit is $fruit"; |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Phix | Phix | <-------- object --------->
| |
+-atom +-sequence
| |
+-integer +-string
|
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #MATLAB_.2F_Octave | MATLAB / Octave | % Create a named function/subroutine/method to compute the dot product of two vectors.
dot(a,b)
% Create a function to compute the cross product of two vectors.
cross(a,b)
% Optionally create a function to compute the scalar triple product of three vectors.
dot(a,cross(b,c))
% Option... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Rust | Rust | const INPUT1: &str = "http%3A%2F%2Ffoo%20bar%2F";
const INPUT2: &str = "google.com/search?q=%60Abdu%27l-Bah%C3%A1";
fn append_frag(text: &mut String, frag: &mut String) {
if !frag.is_empty() {
let encoded = frag.chars()
.collect::<Vec<char>>()
.chunks(2)
.map(|ch| {
... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Scala | Scala | import java.net.{URLDecoder, URLEncoder}
import scala.compat.Platform.currentTime
object UrlCoded extends App {
val original = """http://foo bar/"""
val encoded: String = URLEncoder.encode(original, "UTF-8")
assert(encoded == "http%3A%2F%2Ffoo+bar%2F", s"Original: $original not properly encoded: $encoded")
... |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Nanoquery | Nanoquery | string = str(input("Enter a string: "))
integer = int(input("Enter an integer: ")) |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Neko | Neko | /**
User input/Text, in Neko
Tectonics:
nekoc userinput.neko
neko userinput
*/
var stdin = $loader.loadprim("std@file_stdin", 0)()
var file_read_char = $loader.loadprim("std@file_read_char", 1)
/* Read a line from file f into string s returning length without any newline */
var NEWLINE = 10
var readline = f... |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Standard_ML | Standard ML | open XWindows ;
open Motif ;
val store : string list ref = ref [] ;
val inputWindow = fn () =>
let
val shell = XtAppInitialise "" "demo" "top" [] [ XmNwidth 320, XmNheight 100 ] ;
val main = XmCreateMainWindow shell "main" [ XmNmappedWhenManaged true ] ;
val enter = XmCreateText ... |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Tcl | Tcl | # create entry widget:
pack [entry .e1]
# read its content:
set input [.e get] |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #VBScript | VBScript | Function UrlEncode(url)
For i = 1 To Len(url)
n = Asc(Mid(url,i,1))
If (n >= 48 And n <= 57) Or (n >= 65 And n <= 90) _
Or (n >= 97 And n <= 122) Then
UrlEncode = UrlEncode & Mid(url,i,1)
Else
ChrHex = Hex(Asc(Mid(url,i,1)))
For j = 0 to (Len(ChrHex) / 2) - 1
UrlEncode = U... |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #Vlang | Vlang | import net.urllib
fn main() {
println(urllib.query_escape("http://foo bar/"))
} |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #PHP | PHP | <?php
/**
* @author Elad Yosifon
*/
/*
* PHP is a weak typed language,
* no separation between variable declaration, initialization and assignment.
*
* variable type is defined by the value that is assigned to it.
* a variable name must start with a "$" sign (called "sigil", not a dollar sign).
* variable n... |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #Mercury | Mercury | :- module vector_product.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int, list, string.
main(!IO) :-
A = vector3d(3, 4, 5),
B = vector3d(4, 3, 5),
C = vector3d(-5, -12, -13),
io.format("A . B = %d\n", [i(A `dot_product` B)], !IO),
... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Seed7 | Seed7 | $ include "seed7_05.s7i";
include "encoding.s7i";
const proc: main is func
begin
writeln(fromPercentEncoded("http%3A%2F%2Ffoo%20bar%2F"));
writeln(fromUrlEncoded("http%3A%2F%2Ffoo+bar%2F"));
end func; |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Sidef | Sidef | func urldecode(str) {
str.gsub!('+', ' ');
str.gsub!(/\%([A-Fa-f0-9]{2})/, {|a| 'C'.pack(a.hex)});
return str;
}
say urldecode('http%3A%2F%2Ffoo+bar%2F'); # => "http://foo bar/" |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Nemerle | Nemerle | using System;
using System.Console;
module Input
{
Main() : void
{
Write("Enter a string:");
_ = ReadLine()
mutable entry = 0;
mutable numeric = false;
do
{
Write("Enter 75000:");
numeric = int.TryParse(ReadLine(), out entry);
... |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #NetRexx | NetRexx | /* NetRexx */
options replace format comments java crossref symbols nobinary
checkVal = 75000
say 'Input a string then the number' checkVal
parse ask inString
parse ask inNumber .
say 'Input string:' inString
say 'Input number:' inNumber
if inNumber == checkVal then do
say 'Success! Input number is as requested'... |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #TI-89_BASIC | TI-89 BASIC | Prgm
Dialog
Title "Rosetta Code"
Request "A string", s
DropDown "An integer", {"75000"}, n
EndDlog
74999 + n → n
EndPrgm |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #VBScript | VBScript | strUserIn = InputBox("Enter Data")
Wscript.Echo strUserIn |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #Wren | Wren | import "/fmt" for Fmt
var urlEncode = Fn.new { |url|
var res = ""
for (b in url.bytes) {
if ((b >= 48 && b <= 57) || (b >= 65 && b <= 90) || (b >= 97 && b <= 122)) {
res = res + String.fromByte(b)
} else {
res = res + Fmt.swrite("\%$2X", b)
}
}
return re... |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #XPL0 | XPL0 | code Text=12;
string 0; \use zero-terminated strings
func Encode(S0); \Encode URL string and return its address
char S0;
char HD, S1(80); \BEWARE: very temporary string space returned
int C, I, J;
[HD:= "0123456789ABCDEF"; \hex digits
I:= 0; J:= 0;
repeat C:= S0(I); I:= I+1;
if... |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #PicoLisp | PicoLisp | (use (A B C)
(setq A 1 B 2 C 3)
... ) |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #PL.2FI | PL/I | /* The PROCEDURE block and BEGIN block are used to delimit scopes. */
declare i float; /* external, global variable, excluded from the */
/* local area (BEGIN block) below. */
begin;
declare (i, j) fixed binary; /* local variable */
get list (i, j);
put list (i,j);
end;
/* Exa... |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #MiniScript | MiniScript | vectorA = [3, 4, 5]
vectorB = [4, 3, 5]
vectorC = [-5, -12, -13]
dotProduct = function(x, y)
return x[0]*y[0] + x[1]*y[1] + x[2]*y[2]
end function
crossProduct = function(x, y)
return [x[1]*y[2] - x[2]*y[1], x[2]*y[0] - x[0]*y[2], x[0]*y[1] - x[1]*y[0]]
end function
print "Dot Product = " + dotProduct(vec... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Swift | Swift | import Foundation
let encoded = "http%3A%2F%2Ffoo%20bar%2F"
if let normal = encoded.stringByReplacingPercentEscapesUsingEncoding(NSUTF8StringEncoding) {
println(normal)
} |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Tcl | Tcl | proc urlDecode {str} {
set specialMap {"[" "%5B" "]" "%5D"}
set seqRE {%([0-9a-fA-F]{2})}
set replacement {[format "%c" [scan "\1" "%2x"]]}
set modStr [regsub -all $seqRE [string map $specialMap $str] $replacement]
return [encoding convertfrom utf-8 [subst -nobackslash -novariable $modStr]]
} |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #newLISP | newLISP | (print "Enter an integer: ")
(set 'x (read-line))
(print "Enter a string: ")
(set 'y (read-line)) |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Nim | Nim | import rdstdin, strutils
let str = readLineFromStdin "Input a string: "
let num = parseInt(readLineFromStdin "Input an integer: ") |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Vedit_macro_language | Vedit macro language | Dialog_Input_1(1, "`User Input example`,
`??Enter a string `,
`??Enter a number `") |
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Visual_Basic | Visual Basic | import "graphics" for Canvas, Color
import "input" for Keyboard, Clipboard
import "dome" for Window, Process
var X = 10
var Y = 28
class Main {
construct new() {}
init() {
_text = ""
_enterNum = false
Keyboard.handleText = true
Keyboard.textRegion(X, Y, 8, 8)
}
up... |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #Yabasic | Yabasic | sub encode_url$(s$, exclusions$, spaceplus)
local res$, i, ch$
for i=1 to len(s$)
ch$ = mid$(s$, i, 1)
if ch$ = " " and spaceplus then
ch$ = "+"
elsif not instr(esclusions$, ch$) and (ch$ < "0" or (ch$ > "9" and ch$ < "A") or (ch$ > "Z" and ch$ < "a") or ch$ > "z") then
... |
http://rosettacode.org/wiki/URL_encoding | URL encoding | Task
Provide a function or mechanism to convert a provided string into URL encoding representation.
In URL encoding, special characters, control characters and extended characters
are converted into a percent symbol followed by a two digit hexadecimal code,
So a space character encodes into %20 within the string.
Fo... | #zkl | zkl | var CURL=Import("zklCurl");
CURL.urlEncode("http://foo bar/") //--> "http%3A%2F%2Ffoo%20bar%2F" |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Pony | Pony | var counter: I32 = 10 // mutable variable 'counter' with value 10
let temp: F64 = 36.6 // immutable variable 'temp'
let str: String // immutable variable 'str' with no initial value
str = "i am a string" // variables must be initialized before use
let another_str = "i am another string" // type of variable 'anot... |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #PowerShell | PowerShell | $s = "abc"
$i = 123 |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #.D0.9C.D0.9A-61.2F52 | МК-61/52 | ПП 54 С/П ПП 66 С/П
ИП0 ИП3 ИП6 П3 -> П0 -> П6
ИП1 ИП4 ИП7 П4 -> П1 -> П7
ИП2 ИП5 ИП8 П5 -> П2 -> П8
ПП 66
ИП6 ИП7 ИП8 П2 -> П1 -> П0
ИП9 ИПA ИПB П5 -> П4 -> П3
ПП 54 С/П ПП 66 С/П
ИП0 ИП3 * ИП1 ИП4 * + ИП2 ИП5 * + В/О
ИП1 ИП5 * ИП2 ИП4 * - П9
ИП2 ИП3 * ИП0 ИП5 * - ПA
ИП0 ИП4 * ИП1 ИП3 * - ПB В/О |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #TUSCRIPT | TUSCRIPT |
$$ MODE TUSCRIPT
url_encoded="http%3A%2F%2Ffoo%20bar%2F"
BUILD S_TABLE hex=":%><:><2<>2<%:"
hex=STRINGS (url_encoded,hex), hex=SPLIT(hex)
hex=DECODE (hex,hex)
url_decoded=SUBSTITUTE(url_encoded,":%><2<>2<%:",0,0,hex)
PRINT "encoded: ", url_encoded
PRINT "decoded: ", url_decoded
|
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #UNIX_Shell | UNIX Shell | urldecode() { local u="${1//+/ }"; printf '%b' "${u//%/\\x}"; } |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #NS-HUBASIC | NS-HUBASIC | 10 INPUT "ENTER A STRING: ",STRING$
20 PRINT "YOU ENTERED ";STRING$;"."
30 INPUT "ENTER AN INTEGER: ",INTEGER
40 PRINT "YOU ENTERED";INTEGER;"." |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Oberon-2 | Oberon-2 |
MODULE InputText;
IMPORT
In,
Out;
VAR
i: INTEGER;
str: ARRAY 512 OF CHAR;
BEGIN
Out.String("Enter a integer: ");Out.Flush();In.Int(i);
Out.String("Enter a string: ");Out.Flush();In.String(str);
END InputText.
|
http://rosettacode.org/wiki/User_input/Graphical | User input/Graphical |
In this task, the goal is to input a string and the integer 75000, from graphical user interface.
See also: User input/Text
| #Wren | Wren | import "graphics" for Canvas, Color
import "input" for Keyboard, Clipboard
import "dome" for Window, Process
var X = 10
var Y = 28
class Main {
construct new() {}
init() {
_text = ""
_enterNum = false
Keyboard.handleText = true
Keyboard.textRegion(X, Y, 8, 8)
}
up... |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Prolog | Prolog | mortal(X) :- man(X).
man(socrates). |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #PureBasic | PureBasic | ; Variables are initialized when they appear in sourcecode with default value of 0 and type int
Debug a
; or value "" for a string, they are not case sensitive
Debug b$
; This initializes a double precision float, if type is following the dot
Debug c.d
; They can be initialized with define (double precision float, stri... |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #Modula-2 | Modula-2 | MODULE VectorProducts;
FROM RealStr IMPORT RealToStr;
FROM Terminal IMPORT WriteString,WriteLn,ReadChar;
PROCEDURE WriteReal(r : REAL);
VAR buf : ARRAY[0..31] OF CHAR;
BEGIN
RealToStr(r, buf);
WriteString(buf)
END WriteReal;
TYPE Vector = RECORD
a,b,c : REAL;
END;
PROCEDURE Dot(u,v : Vector) : REAL;
B... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #VBScript | VBScript | Function RegExTest(str,patrn)
Dim regEx
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Pattern = patrn
RegExTest = regEx.Test(str)
End Function
Function URLDecode(sStr)
Dim str,code,a0
str=""
code=sStr
code=Replace(code,"+"," ")
While len(code)>0
If InStr(code,"%"... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Vlang | Vlang | import net.urllib
fn main() {
for escaped in [
"http%3A%2F%2Ffoo%20bar%2F",
"google.com/search?q=%60Abdu%27l-Bah%C3%A1",
] {
u := urllib.query_unescape(escaped)?
println(u)
}
} |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Objeck | Objeck |
use IO;
bundle Default {
class Hello {
function : Main(args : String[]) ~ Nil {
string := Console->GetInstance()->ReadString();
string->PrintLine();
number := Console->GetInstance()->ReadString()->ToInt();
number->PrintLine();
}
}
}
|
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #OCaml | OCaml | print_string "Enter a string: ";
let str = read_line () in
print_string "Enter an integer: ";
let num = read_int () in
Printf.printf "%s%d\n" str num |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Python | Python |
# these examples, respectively, refer to integer, float, boolean, and string objects
example1 = 3
example2 = 3.0
example3 = True
example4 = "hello"
# example1 now refers to a string object.
example1 = "goodbye"
|
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Quackery | Quackery | [ stack ] is mystack |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #Nemerle | Nemerle | using System.Console;
module VectorProducts3d
{
Dot(x : int * int * int, y : int * int * int) : int
{
def (x1, x2, x3) = x;
def (y1, y2, y3) = y;
(x1 * y1) + (x2 * y2) + (x3 * y3)
}
Cross(x : int * int * int, y : int * int * int) : int * int * int
{
def (x1, x2, x... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Wren | Wren | import "/fmt" for Conv
var urlDecode = Fn.new { |enc|
var res = ""
var i = 0
while (i < enc.count) {
var c = enc[i]
if (c == "\%") {
var b = Conv.atoi(enc[i+1..i+2], 16)
res = res + String.fromByte(b)
i = i + 3
} else {
res = res + c
... |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Octave | Octave | % read a string ("s")
s = input("Enter a string: ", "s");
% read a GNU Octave expression, which is evaluated; e.g.
% 5/7 gives 0.71429
i = input("Enter an expression: ");
% parse the input for an integer
printf("Enter an integer: ");
ri = scanf("%d");
% show the values
disp(s);
disp(i);
disp(ri); |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #R | R | foo <- 3.4
bar = "abc" |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Racket | Racket |
#lang racket
;; define a variable and initialize it
(define foo 0)
;; increment it
(set! foo (add1 foo))
;; Racket is lexically scoped, which makes local variables work:
(define (bar)
(define foo 100)
(set! foo (add1 foo))
foo)
(bar) ; -> 101
;; and it also makes it possible to have variables with a globa... |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #Never | Never | func printv(a[d] : float) -> int {
prints("[" + a[0] + ", " + a[1] + ", " + a[2] + "]\n");
0
}
func dot(a[d1] : float, b[d2] : float) -> float {
a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
}
func cross(a[d1] : float, b[d2] : float) -> [_] : float {
[ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2]... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #XPL0 | XPL0 | code Text=12;
string 0; \use zero-terminated strings
func Decode(S0); \Decode URL string and return its address
char S0;
char S1(80); \BEWARE: very temporary string space returned
int C, N, I, J;
[I:= 0; J:= 0;
repeat C:= S0(I); I:= I+1; \get char
if C=^%... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #Yabasic | Yabasic | sub decode_url$(s$)
local res$, ch$
while(s$ <> "")
ch$ = left$(s$, 1)
if ch$ = "%" then
ch$ = chr$(dec(mid$(s$, 2, 2)))
s$ = right$(s$, len(s$) - 3)
else
if ch$ = "+" ch$ = " "
s$ = right$(s$, len(s$) - 1)
endif
res$ = res$ + ch... |
http://rosettacode.org/wiki/URL_decoding | URL decoding | This task (the reverse of URL encoding and distinct from URL parser) is to provide a function
or mechanism to convert an URL-encoded string into its original unencoded form.
Test cases
The encoded string "http%3A%2F%2Ffoo%20bar%2F" should be reverted to the unencoded form "http://foo bar/".
Th... | #zkl | zkl | "http%3A%2F%2Ffoo%20bar%2F".pump(String, // push each char through these fcns:
fcn(c){ if(c=="%") return(Void.Read,2); return(Void.Skip,c) },// %-->read 2 chars else pass through
fcn(_,b,c){ (b+c).toInt(16).toChar() }) // "%" (ignored) "3"+"1"-->0x31-->"1" |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Oforth | Oforth | import: console
: testInput{
| s n |
System.Console askln ->s
while (System.Console askln asInteger dup ->n isNull) [ "Not an integer" println ]
System.Out "Received : " << s << " and " << n << cr ; |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Oz | Oz | declare
StdIn = {New class $ from Open.file Open.text end init(name:stdin)}
StringInput
Num = {NewCell 0}
in
{System.printInfo "Enter a string: "}
StringInput = {StdIn getS($)}
for until:@Num == 75000 do
{System.printInfo "Enter 75000: "}
Line = {StdIn getS($)}
in
Num := try {String.toInt... |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Raku | Raku |
my @y = <A B C D>; # Array of strings 'A', 'B', 'C', and 'D'
say @y[2]; # the @-sigil requires the container to implement the role Positional
@y[1,2] = 'x','y'; # that's where subscripts and many other things come from
say @y; # OUTPUT«[A x y D]» # we start to count at 0 btw.
my $x = @y; # $x is now a reference fo... |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #Nim | Nim | import strformat, strutils
type Vector3 = array[1..3, float]
proc `$`(a: Vector3): string =
result = "("
for x in a:
result.addSep(", ", 1)
result.add &"{x}"
result.add ')'
proc cross(a, b: Vector3): Vector3 =
result = [a[2]*b[3] - a[3]*b[2], a[3]*b[1] - a[1]*b[3], a[1]*b[2] - a[2]*b[1]]
proc do... |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #PARI.2FGP | PARI/GP | s=input();
n=eval(input()); |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Pascal | Pascal | program UserInput(input, output);
var i : Integer;
s : String;
begin
write('Enter an integer: ');
readln(i);
write('Enter a string: ');
readln(s)
end. |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Rascal | Rascal | Type Name = Exp; |
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #REXX | REXX | aa = 10 /*assigns chars 10 ───► AA */
bb = '' /*assigns a null value ───► BB */
cc = 2*10 /*assigns chars 20 ───► CC */
dd = 'Adam' /*assigns chars Adam ───► DD */
ee = "Adam" ... |
http://rosettacode.org/wiki/Vector_products | Vector products | A vector is defined as having three dimensions as being represented by an ordered collection of three numbers: (X, Y, Z).
If you imagine a graph with the x and y axis being at right angles to each other and having a third, z axis coming out of the page, then a triplet of numbers, (X, Y, Z) would repr... | #Objeck | Objeck | bundle Default {
class VectorProduct {
function : Main(args : String[]) ~ Nil {
a := Vector3D->New(3.0, 4.0, 5.0);
b := Vector3D->New(4.0, 3.0, 5.0);
c := Vector3D->New(-5.0, -12.0, -13.0);
a->Dot(b)->Print();
a->Cross(b)->Print();
a->ScaleTrip(b, c)->Print();
a->Vecto... |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Perl | Perl | print "Enter a string: ";
my $string = <>;
print "Enter an integer: ";
my $integer = <>; |
http://rosettacode.org/wiki/User_input/Text | User input/Text | User input/Text is part of Short Circuit's Console Program Basics selection.
Task
Input a string and the integer 75000 from the text console.
See also: User input/Graphical
| #Phix | Phix | ?prompt_string("Enter any string:")
?prompt_number("Enter the number 75000:",{75000,75000})
|
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Ring | Ring |
<Variable Name> = <Value>
|
http://rosettacode.org/wiki/Variables | Variables | Task
Demonstrate a language's methods of:
variable declaration
initialization
assignment
datatypes
scope
referencing, and
other variable related facilities
| #Ruby | Ruby | $a_global_var = 5
class Demo
@@a_class_var = 6
A_CONSTANT = 8
def initialize
@an_instance_var = 7
end
def incr(a_local_var)
@an_instance_var += a_local_var
end
end |
Subsets and Splits
Rosetta Code COBOL Python Hard Tasks
Identifies and retrieves challenging tasks that exist in both COBOL and Python, revealing cross-language programming patterns and difficulty levels for comparative analysis.
Rosetta Code Task Comparisons
Identifies tasks common to both COBOL and Python languages that are described as having difficulty levels, revealing cross-language task similarities and providing useful comparative programming examples.
Select Specific Languages Codes
Retrieves specific programming language names and codes from training data, providing basic filtering but limited analytical value beyond identifying these particular languages.