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/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Phixmonti | Phixmonti | "12345" tonum 1 + tostr |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #PHP | PHP | $s = "12345";
$s++; |
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 |... | #MMIX | MMIX | // main registers
p IS $255 % pointer
pp GREG % backup for p
A GREG % first int
B GREG % second int
// arg registers
argc IS $0
argv IS $1
LOC Data_Segment
GREG @
ERR BYTE "Wrong number of arguments",#a,0
ILLH BYTE "Argument -> ",0
ILLT BYTE " <- contains an illegal character",#a,0
LT BYTE "A is less than B",#a... |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Ioke | Ioke |
connection = URL new("https://sourceforge.net") openConnection
scanner = Scanner new(connection getInputStream)
while(scanner hasNext,
scanner next println
)
|
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #J | J |
#page=: gethttp'https://sourceforge.net'
0
#page=: '--no-check-certificate' gethttp'https://sourceforge.net'
900
|
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Java | Java |
URL url = new URL("https://sourceforge.net");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
Scanner scanner = new Scanner(connection.getInputStream());
while (scanner.hasNext()) {
System.out.println(scanner.next());
}
|
http://rosettacode.org/wiki/HTTP | HTTP | Task
Access and print a URL's content (the located resource) to the console.
There is a separate task for HTTPS Requests.
| #8th | 8th |
"http://www.rosettacode.org" net:get drop >s .
|
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation | Horner's rule for polynomial evaluation | A fast scheme for evaluating a polynomial such as:
−
19
+
7
x
−
4
x
2
+
6
x
3
{\displaystyle -19+7x-4x^{2}+6x^{3}\,}
when
x
=
3
{\displaystyle x=3\;}
.
is to arrange the computation as follows:
(
(
(
(
0
)
x
+
6
)
x
+
(
−
4
)
)
x
+
7
)
x
+
(
−
19
)
{\displaystyle ((((0)x+6)x+(-4))x... | #11l | 11l | F horner(coeffs, x)
V acc = 0
L(c) reversed(coeffs)
acc = acc * x + c
R acc
print(horner([-19, 7, -4, 6], 3)) |
http://rosettacode.org/wiki/Huffman_coding | Huffman coding | Huffman encoding is a way to assign binary codes to symbols that reduces the overall number of bits used to encode a typical string of those symbols.
For example, if you use letters as symbols and have details of the frequency of occurrence of those letters in typical strings, then you could just encode each letter wi... | #Clojure | Clojure | (require '[clojure.pprint :refer :all])
(defn probs [s]
(let [freqs (frequencies s) sum (apply + (vals freqs))]
(into {} (map (fn [[k v]] [k (/ v sum)]) freqs))))
(defn init-pq [weighted-items]
(let [comp (proxy [java.util.Comparator] []
(compare [a b] (compare (:priority a) (:priority b))))... |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #Erlang | Erlang | 1> erlang:system_info(wordsize).
4 |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #F.23 | F# | open System
open System.Runtime.InteropServices
open System.Diagnostics
[<DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)>]
extern bool IsWow64Process(nativeint hProcess, bool &wow64Process);
let answerHostInfo =
let Is64Bit() =
let mutable f64Bit = false;
... |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #E | E | makeCommand("hostname")()[0].trim() |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Emacs_Lisp | Emacs Lisp | (system-name) |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Erlang | Erlang | Host = net_adm:localhost(). |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #SNOBOL4 | SNOBOL4 | * IBAN - International Bank Account Number validation
DEFINE('ibantable()') :(iban_table_end)
ibantable
ibantable = TABLE(70)
ibancodes =
+ 'AL28AD24AT20AZ28BE16BH22BA20BR29BG22CR21'
+ 'HR21CY28CZ24DK18DO28EE20FO18FI18FR27GE22'
+ 'DE22GI23GR27GL18GT28HU28... |
http://rosettacode.org/wiki/Hough_transform | Hough transform | Task
Implement the Hough transform, which is used as part of feature extraction with digital images.
It is a tool that makes it far easier to identify straight lines in the source image, whatever their orientation.
The transform maps each point in the target image,
(
ρ
,
θ
)
{\displaystyle (\rho ,\theta )}
, ... | #MATLAB | MATLAB | import lenientops, math
import grayscale_image
const White = 255
func houghTransform*(img: GrayImage; hx = 460; hy = 360): GrayImage =
assert not img.isNil
assert hx > 0 and hy > 0
assert (hy and 1) == 0, "hy argument must be even"
result = newGrayImage(hx, hy)
result.fill(White)
let rMax = hypot(im... |
http://rosettacode.org/wiki/Hough_transform | Hough transform | Task
Implement the Hough transform, which is used as part of feature extraction with digital images.
It is a tool that makes it far easier to identify straight lines in the source image, whatever their orientation.
The transform maps each point in the target image,
(
ρ
,
θ
)
{\displaystyle (\rho ,\theta )}
, ... | #Nim | Nim | import lenientops, math
import grayscale_image
const White = 255
func houghTransform*(img: GrayImage; hx = 460; hy = 360): GrayImage =
assert not img.isNil
assert hx > 0 and hy > 0
assert (hy and 1) == 0, "hy argument must be even"
result = newGrayImage(hx, hy)
result.fill(White)
let rMax = hypot(im... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #MathCortex | MathCortex | I = eye(10) |
http://rosettacode.org/wiki/I_before_E_except_after_C | I before E except after C | The phrase "I before E, except after C" is a
widely known mnemonic which is supposed to help when spelling English words.
Task
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt,
check if the two sub-clauses of the phrase are plausible individually:
"I before E when not pre... | #UNIX_Shell | UNIX Shell | #!/bin/sh
matched() {
grep -Poe "$1" unixdict.txt | wc -l
}
check() {
local num_for="$(matched "$3")"
local num_against="$(matched "$2")"
if [ "$num_for" -le "$(expr 2 \* "$num_against")" ]; then
echo "Clause $1 not plausible ($num_for examples; $num_against counterexamples)"
return 1
else
ech... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Picat | Picat | go =>
% integer
Int = "123",
println(int=Int),
println(parse_term=Int.parse_term+1),
println(to_int=Int.to_int+1), % assumes integer
nl,
% float
Float = "122.5",
println(float=Float),
println(parse_term=Float.parse_term+1),
println(to_float=Float.to_float+1),
nl.
|
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #PicoLisp | PicoLisp | (format (inc (format "123456"))) |
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 |... | #Modula-2 | Modula-2 | MODULE IntCompare;
IMPORT InOut;
VAR
A, B: INTEGER;
BEGIN
InOut.ReadInt(A);
InOut.ReadInt(B);
InOut.WriteInt(A, 1);
IF A < B THEN
InOut.WriteString(' is less than ')
ELSIF A = B THEN
InOut.WriteString(' is equal to ')
ELSE
InOut.WriteString(' is greater than ')
END;
InOut.WriteInt(... |
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 |... | #Modula-3 | Modula-3 | MODULE Main;
FROM IO IMPORT Put, GetInt;
FROM Fmt IMPORT Int;
VAR a,b: INTEGER;
BEGIN
a := GetInt();
b := GetInt();
IF a < b THEN
Put(Int(a) & " is less than " & Int(b) & "\n");
ELSIF a = b THEN
Put(Int(a) & " is equal to " & Int(b) & "\n");
ELSIF a > b THEN
Put(Int(a) & " is greater than "... |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #JavaScript | JavaScript | fetch("https://sourceforge.net").then(function (response) {
return response.text();
}).then(function (body) {
return body;
}); |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Julia | Julia | # v0.6.0
using Requests
str = readstring(get("https://sourceforge.net/")) |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Kotlin | Kotlin | // version 1.1.2
import java.net.URL
import javax.net.ssl.HttpsURLConnection
import java.io.InputStreamReader
import java.util.Scanner
fun main(args: Array<String>) {
val url = URL("https://en.wikipedia.org/wiki/Main_Page")
val connection = url.openConnection() as HttpsURLConnection
val isr = InputStreamR... |
http://rosettacode.org/wiki/HTTP | HTTP | Task
Access and print a URL's content (the located resource) to the console.
There is a separate task for HTTPS Requests.
| #ABAP | ABAP |
report z_http.
cl_http_client=>create_by_url(
exporting
url = `http://rosettacode.org/robots.txt`
importing
client = data(http_client)
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4 ).
if sy-subrc <> 0... |
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation | Horner's rule for polynomial evaluation | A fast scheme for evaluating a polynomial such as:
−
19
+
7
x
−
4
x
2
+
6
x
3
{\displaystyle -19+7x-4x^{2}+6x^{3}\,}
when
x
=
3
{\displaystyle x=3\;}
.
is to arrange the computation as follows:
(
(
(
(
0
)
x
+
6
)
x
+
(
−
4
)
)
x
+
7
)
x
+
(
−
19
)
{\displaystyle ((((0)x+6)x+(-4))x... | #360_Assembly | 360 Assembly | * Horner's rule for polynomial evaluation - 07/10/2015
HORNER CSECT
USING HORNER,R15 set base register
SR R5,R5 accumulator=0
LA R2,N i=number_of_coeff
LOOP M R4,X accumulator=accumulator*x
LR R1,R2 ... |
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation | Horner's rule for polynomial evaluation | A fast scheme for evaluating a polynomial such as:
−
19
+
7
x
−
4
x
2
+
6
x
3
{\displaystyle -19+7x-4x^{2}+6x^{3}\,}
when
x
=
3
{\displaystyle x=3\;}
.
is to arrange the computation as follows:
(
(
(
(
0
)
x
+
6
)
x
+
(
−
4
)
)
x
+
7
)
x
+
(
−
19
)
{\displaystyle ((((0)x+6)x+(-4))x... | #ACL2 | ACL2 | (defun horner (ps x)
(if (endp ps)
0
(+ (first ps)
(* x (horner (rest ps) x))))) |
http://rosettacode.org/wiki/Horizontal_sundial_calculations | Horizontal sundial calculations | Task
Create a program that calculates the hour, sun hour angle, dial hour line angle from 6am to 6pm for an operator entered location.
For example, the user is prompted for a location and inputs the latitude and longitude 4°57′S 150°30′W (4.95°S 150.5°W of Jules Verne's Lincoln Island, aka Ernest Legouve Reef), wit... | #11l | 11l | V lat = Float(input(‘Enter latitude => ’))
V lng = Float(input(‘Enter longitude => ’))
V ref = Float(input(‘Enter legal meridian => ’))
print()
V slat = sin(radians(lat))
print(‘ sine of latitude: #.3’.format(slat))
print(‘ diff longitude: #.3’.format(lng - ref))
print()
print(‘Hour, sun hour a... |
http://rosettacode.org/wiki/Huffman_coding | Huffman coding | Huffman encoding is a way to assign binary codes to symbols that reduces the overall number of bits used to encode a typical string of those symbols.
For example, if you use letters as symbols and have details of the frequency of occurrence of those letters in typical strings, then you could just encode each letter wi... | #CoffeeScript | CoffeeScript |
huffman_encoding_table = (counts) ->
# counts is a hash where keys are characters and
# values are frequencies;
# return a hash where keys are codes and values
# are characters
build_huffman_tree = ->
# returns a Huffman tree. Each node has
# cnt: total frequency of all chars in subtree
# ... |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #Factor | Factor | USING: alien.c-types alien.data io layouts ;
"Word size: " write cell 8 * .
"Endianness: " write little-endian? "little" "big" ? print |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #Forth | Forth | : endian
cr 1 cells . ." address units per cell"
s" ADDRESS-UNIT-BITS" environment? if cr . ." bits per address unit" then
cr 1 here ! here c@ if ." little" else ." big" then ." endian" ; |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #F.23 | F# | printfn "%s" (System.Net.Dns.GetHostName()) |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Factor | Factor | USE: io.sockets
host-name |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Forth | Forth | include unix/socket.fs
hostname type |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #Standard_ML | Standard ML | (* country_code : string -> int *)
(* Get the length of a valid IBAN given the two chars long country code *)
fun country_code (str : string) : int =
case str of
"AL" => 28 | "AD" => 24 | "AT" => 20 | "AZ" => 28
| "BE" => 16 | "BH" => 22 | "BA" => 20 | "BR" => 29
| "BG" => 22 | "CR" => 21 | "HR" => 21 | "CY" ... |
http://rosettacode.org/wiki/Hough_transform | Hough transform | Task
Implement the Hough transform, which is used as part of feature extraction with digital images.
It is a tool that makes it far easier to identify straight lines in the source image, whatever their orientation.
The transform maps each point in the target image,
(
ρ
,
θ
)
{\displaystyle (\rho ,\theta )}
, ... | #Perl | Perl | use strict;
use warnings;
use Imager;
use constant pi => 3.14159265;
sub hough {
my($im) = shift;
my($width) = shift || 460;
my($height) = shift || 360;
$height = 2 * int $height/2;
$height = 2 * int $height/2;
my($xsize, $ysize) = ($im->getwidth, $im->getheight);
my $ht = Image... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | IdentityMatrix[4] |
http://rosettacode.org/wiki/I_before_E_except_after_C | I before E except after C | The phrase "I before E, except after C" is a
widely known mnemonic which is supposed to help when spelling English words.
Task
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt,
check if the two sub-clauses of the phrase are plausible individually:
"I before E when not pre... | #VBScript | VBScript |
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set srcFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_
"\unixdict.txt",1,False,0)
cei = 0 : cie = 0 : ei = 0 : ie = 0
Do Until srcFile.AtEndOfStream
word = srcFile.ReadLine
If InStr(word,"cei") Then
cei = cei + 1
ElseIf... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Pike | Pike | string number = "0";
number = (string)((int)number+1);
Result: "1" |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #PL.2FI | PL/I | declare s picture '999999999';
s = '123456789';
s = s + 1;
put skip list (s); |
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 |... | #MUMPS | MUMPS | INTCOMP
NEW A,B
INTCOMPREAD
READ !,"Enter an integer to test: ",A
READ !,"Enter another integer: ",B
IF (+A\1'=A)!(+B\1'=B) WRITE !!,"Please enter two integers.",! GOTO INTCOMPREAD
IF A<B WRITE !,A," is less than ",B
IF A=B WRITE !,A," is equal to ",B
IF A>B WRITE !,A," is greater than ",B
KILL A,B
QUIT |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Lasso | Lasso | local(x = curl('https://sourceforge.net'))
local(y = #x->result)
#y->asString |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Lingo | Lingo | ch = xtra("Curl").new()
CURLOPT_URL = 10002
ch.setOption(CURLOPT_URL, "https://sourceforge.net")
res = ch.exec(1)
if integerP(res) then
put "Error:" && curl_error(res)
else
put "Result:" && res.readRawString(res.length)
end if
-- "Result: <!doctype html> ..." |
http://rosettacode.org/wiki/HTTP | HTTP | Task
Access and print a URL's content (the located resource) to the console.
There is a separate task for HTTPS Requests.
| #ActionScript | ActionScript |
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.*;
public class RequestExample extends Sprite
{
public function RequestExample()
{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadComple... |
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation | Horner's rule for polynomial evaluation | A fast scheme for evaluating a polynomial such as:
−
19
+
7
x
−
4
x
2
+
6
x
3
{\displaystyle -19+7x-4x^{2}+6x^{3}\,}
when
x
=
3
{\displaystyle x=3\;}
.
is to arrange the computation as follows:
(
(
(
(
0
)
x
+
6
)
x
+
(
−
4
)
)
x
+
7
)
x
+
(
−
19
)
{\displaystyle ((((0)x+6)x+(-4))x... | #Action.21 | Action! | INT FUNC Horner(INT ARRAY coeffs INT count,x)
INT v,i
v=0 i=count-1
WHILE i>=0
DO
v=v*x+coeffs(i)
i==-1
OD
RETURN (v)
PROC Main()
INT ARRAY coeffs=[65517 7 65532 6]
INT res,x=[3],i,count=[4]
PrintF("x=%I%E",x)
FOR i=0 TO count-1
DO
PrintI(coeffs(i))
IF i=1 THEN
Print("x")... |
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation | Horner's rule for polynomial evaluation | A fast scheme for evaluating a polynomial such as:
−
19
+
7
x
−
4
x
2
+
6
x
3
{\displaystyle -19+7x-4x^{2}+6x^{3}\,}
when
x
=
3
{\displaystyle x=3\;}
.
is to arrange the computation as follows:
(
(
(
(
0
)
x
+
6
)
x
+
(
−
4
)
)
x
+
7
)
x
+
(
−
19
)
{\displaystyle ((((0)x+6)x+(-4))x... | #Ada | Ada | with Ada.Float_Text_IO; use Ada.Float_Text_IO;
procedure Horners_Rule is
type Coef is array(Positive range <>) of Float;
function Horner(Coeffs: Coef; Val: Float) return Float is
Res : Float := 0.0;
begin
for P in reverse Coeffs'Range loop
Res := Res*Val + Coeffs(P);
end loop;
... |
http://rosettacode.org/wiki/Horizontal_sundial_calculations | Horizontal sundial calculations | Task
Create a program that calculates the hour, sun hour angle, dial hour line angle from 6am to 6pm for an operator entered location.
For example, the user is prompted for a location and inputs the latitude and longitude 4°57′S 150°30′W (4.95°S 150.5°W of Jules Verne's Lincoln Island, aka Ernest Legouve Reef), wit... | #Ada | Ada | with Ada.Text_IO;
with Ada.Numerics.Elementary_Functions;
procedure Sundial is
use Ada.Numerics.Elementary_Functions;
use Ada.Numerics;
package Float_IO is new Ada.Text_IO.Float_IO (Float);
Latitude, Longitude, Meridian : Float;
Latitude_Sine : Float;
begin
Ada.Text_IO.Put ("Enter la... |
http://rosettacode.org/wiki/Huffman_coding | Huffman coding | Huffman encoding is a way to assign binary codes to symbols that reduces the overall number of bits used to encode a typical string of those symbols.
For example, if you use letters as symbols and have details of the frequency of occurrence of those letters in typical strings, then you could just encode each letter wi... | #Common_Lisp | Common Lisp | (defstruct huffman-node
(weight 0 :type number)
(element nil :type t)
(encoding nil :type (or null bit-vector))
(left nil :type (or null huffman-node))
(right nil :type (or null huffman-node)))
(defun initial-huffman-nodes (sequence &key (test 'eql))
(let* ((length (length sequence))
(increment (... |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #Fortran | Fortran | integer :: i
character(len=1) :: c(20)
equivalence (c, i)
WRITE(*,*) bit_size(1) ! number of bits in the default integer type
! which may (or may not!) equal the word size
i = 1
IF (ichar(c(1)) == 0) THEN
WRITE(*,*) "Big Endian"
ELSE
WRITE(*,*) "Little End... |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #FreeBASIC | FreeBASIC | ' FB 1.05.0 Win64 (so little endian, 8 byte word size, expected)
' uses intrinsic defines, set by the compiler
#Ifdef __FB_64BIT__
Print "Host has an 8 byte word size"
#Else
Print "Host has a 4 byte word size"
#EndIf
#Ifdef __FB_BIGENDIAN__
Print "Host is big endian"
#Else
Print "Host is little endian"
#E... |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Fortran | Fortran | program HostTest
character(len=128) :: name
call hostnm(name)
print *, name
end program HostTest |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #FreeBASIC | FreeBASIC | ' FB 1.05.0 Win64
' On Windows 10, the command line utility HOSTNAME.EXE prints the 'hostname' to the console.
' We can execute this remotely and read from its 'stdin' stream as follows:
Dim As String hostname
Open Pipe "hostname" For Input As #1
Input #1, hostname
Close #1
Print hostname
Print
Print "Press any key... |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #Tcl | Tcl | proc verifyIBAN {iban} {
# Normalize by up-casing and stripping illegal chars (e.g., space)
set iban [regsub -all {[^A-Z0-9]+} [string toupper $iban] ""]
# Get the expected length from the country-code part
switch [string range $iban 0 1] {
NO { set len 15 }
BE { set len 16 }
DK - FI - FO - GL - NL {... |
http://rosettacode.org/wiki/Hough_transform | Hough transform | Task
Implement the Hough transform, which is used as part of feature extraction with digital images.
It is a tool that makes it far easier to identify straight lines in the source image, whatever their orientation.
The transform maps each point in the target image,
(
ρ
,
θ
)
{\displaystyle (\rho ,\theta )}
, ... | #Phix | Phix | -- demo\rosetta\Hough_transform.exw
without js -- IupImage, imImage, im_width/height/pixel, allocate,
-- imFileImageLoadBitmap, IupImageFromImImage
include pGUI.e
function hypot(atom a,b) return sqrt(a*a+b*b) end function
function hough_transform(imImage im, integer width=460, height=360)
height = 2*... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #MATLAB_.2F_Octave | MATLAB / Octave | I = eye(10) |
http://rosettacode.org/wiki/I_before_E_except_after_C | I before E except after C | The phrase "I before E, except after C" is a
widely known mnemonic which is supposed to help when spelling English words.
Task
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt,
check if the two sub-clauses of the phrase are plausible individually:
"I before E when not pre... | #Visual_Basic_.NET | Visual Basic .NET | Option Compare Binary
Option Explicit On
Option Infer On
Option Strict On
Imports System.Text.RegularExpressions
#Const USE_REGEX = False
Module Program
' Supports both local and remote files
Const WORDLIST_URI = "http://wiki.puzzlers.org/pub/wordlists/unixdict.txt"
' The support factor of a word ... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Plain_English | Plain English | To increment a numerical string:
Convert the numerical string to a number.
Add 1 to the number.
Put the number into the numerical string. |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Plain_TeX | Plain TeX | \newcount\acounter
\def\stringinc#1{\acounter=#1\relax%
\advance\acounter by 1\relax%
\number\acounter}
The number 12345 is followed by \stringinc{12345}.
\bye |
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 |... | #Nanoquery | Nanoquery | print "enter first integer: "
first = int(input())
print "enter second integer: "
second = int(input())
if first = second
println "the two integers are equal"
else if first < second
println first + " is less than " + second
else if first > second
println first + " is greater than " + second
end |
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 |... | #Nemerle | Nemerle | using System;
using System.Console;
module IntComp
{
Main() : void
{
def ReadInt() : int {Int32.Parse(ReadLine())}
def WriteResult(x : int, y : int, res : string) : void
{WriteLine($"$x is $res $y")}
def a = ReadInt();
def b = ReadInt();
match(a)
{
... |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #LiveCode | LiveCode | libURLSetSSLVerification true --check cert
get URL "https://sourceforge.net/" |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #LSL | LSL | string sURL = "https://SourceForge.Net/";
key kHttpRequestId;
default {
state_entry() {
kHttpRequestId = llHTTPRequest(sURL, [], "");
}
http_response(key kRequestId, integer iStatus, list lMetaData, string sBody) {
if(kRequestId==kHttpRequestId) {
llOwnerSay("Status="+(string)iStatus);
integer x = 0;
fo... |
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Lua | Lua |
local request = require('http.request')
local headers, stream = request.new_from_uri("https://sourceforge.net/"):go()
local body = stream:get_body_as_string()
local status = headers:get(':status')
io.write(string.format('Status: %d\nBody: %s\n', status, body)
|
http://rosettacode.org/wiki/HTTP | HTTP | Task
Access and print a URL's content (the located resource) to the console.
There is a separate task for HTTPS Requests.
| #Ada | Ada |
with Ada.Text_IO; use Ada.Text_IO;
with AWS.Client;
with AWS.Response;
procedure HTTP_Request is
begin
Put_Line (AWS.Response.Message_Body (AWS.Client.Get (URL => "http://www.rosettacode.org")));
end HTTP_Request;
|
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation | Horner's rule for polynomial evaluation | A fast scheme for evaluating a polynomial such as:
−
19
+
7
x
−
4
x
2
+
6
x
3
{\displaystyle -19+7x-4x^{2}+6x^{3}\,}
when
x
=
3
{\displaystyle x=3\;}
.
is to arrange the computation as follows:
(
(
(
(
0
)
x
+
6
)
x
+
(
−
4
)
)
x
+
7
)
x
+
(
−
19
)
{\displaystyle ((((0)x+6)x+(-4))x... | #Aime | Aime | real
horner(list coeffs, real x)
{
real c, z;
z = 0;
for (, c of coeffs) {
z *= x;
z += c;
}
z;
}
integer
main(void)
{
o_(horner(list(-19r, 7.0, -4r, 6r), 3), "\n");
0;
} |
http://rosettacode.org/wiki/Home_primes | Home primes |
This page uses content from Wikipedia. The original article was at Home prime. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
In number theory, the home prime HP(n) of an integer n greater than 1 is... | #Factor | Factor | USING: formatting kernel make math math.parser math.primes
math.primes.factors math.ranges present prettyprint sequences
sequences.extras ;
: squish ( seq -- n ) [ present ] map-concat dec> ;
: next ( m -- n ) factors squish ; inline
: (chain) ( n -- ) [ dup prime? ] [ dup , next ] until , ;
: chain ( n -- seq ... |
http://rosettacode.org/wiki/Horizontal_sundial_calculations | Horizontal sundial calculations | Task
Create a program that calculates the hour, sun hour angle, dial hour line angle from 6am to 6pm for an operator entered location.
For example, the user is prompted for a location and inputs the latitude and longitude 4°57′S 150°30′W (4.95°S 150.5°W of Jules Verne's Lincoln Island, aka Ernest Legouve Reef), wit... | #ALGOL_68 | ALGOL 68 | BEGIN
REAL lat, slat, lng, ref;
print ( "Enter latitude => " ); read (lat);
print ( "Enter longitude => " ); read (lng);
print ( "Enter legal meridian => " ); read (ref);
new line(stand out);
slat := sin(lat*2*pi/360) ;
print ( (" sine of latitude: ", float(slat,8,2,1), new line ) );
p... |
http://rosettacode.org/wiki/Huffman_coding | Huffman coding | Huffman encoding is a way to assign binary codes to symbols that reduces the overall number of bits used to encode a typical string of those symbols.
For example, if you use letters as symbols and have details of the frequency of occurrence of those letters in typical strings, then you could just encode each letter wi... | #D | D | import std.stdio, std.algorithm, std.typecons, std.container, std.array;
auto encode(alias eq, R)(Group!(eq, R) sf) /*pure nothrow @safe*/ {
auto heap = sf.map!(s => tuple(s[1], [tuple(s[0], "")]))
.array.heapify!q{b < a};
while (heap.length > 1) {
auto lo = heap.front; heap.removeFr... |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #Frink | Frink |
println["Word size: " + callJava["java.lang.System", "getProperty", "sun.arch.data.model"]]
println["Endianness: " + callJava["java.lang.System", "getProperty", "sun.cpu.endian"]]
|
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #Go | Go | package main
import (
"fmt"
"io/ioutil"
"runtime"
"strconv"
"strings"
"unsafe"
)
func main() {
fmt.Println(runtime.Version(), runtime.GOOS, runtime.GOARCH)
// Inspect a uint32 variable to determine endianness.
x := uint32(0x01020304)
switch *(*byte)(unsafe.Pointer(&x)) {
case 0x01:
fmt.Println("big e... |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #friendly_interactive_shell | friendly interactive shell | hostname |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Frink | Frink | callJava["java.net.InetAddress", "getLocalHost"].getHostName[] |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Gambas | Gambas | Public Sub Main()
Print System.Host
End |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #UNIX_Shell | UNIX Shell | declare -A base36=(
[A]=10 [B]=11 [C]=12 [D]=13 [E]=14 [F]=15 [G]=16 [H]=17 [I]=18
[J]=19 [K]=20 [L]=21 [M]=22 [N]=23 [O]=24 [P]=25 [Q]=26 [R]=27
[S]=28 [T]=29 [U]=30 [V]=31 [W]=32 [X]=33 [Y]=34 [Z]=35
)
function is_iban {
local -u acct=${1//[^[:alnum:]]/}
acct=${acct:4}${acct:0:4}
local i cha... |
http://rosettacode.org/wiki/Hough_transform | Hough transform | Task
Implement the Hough transform, which is used as part of feature extraction with digital images.
It is a tool that makes it far easier to identify straight lines in the source image, whatever their orientation.
The transform maps each point in the target image,
(
ρ
,
θ
)
{\displaystyle (\rho ,\theta )}
, ... | #Python | Python |
from math import hypot, pi, cos, sin
from PIL import Image
def hough(im, ntx=460, mry=360):
"Calculate Hough transform."
pim = im.load()
nimx, mimy = im.size
mry = int(mry/2)*2 #Make sure that this is even
him = Image.new("L", (ntx, mry), 255)
phim = him.load()
rmax = hypot(... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #Maxima | Maxima | ident(4);
/* matrix([1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]) */ |
http://rosettacode.org/wiki/I_before_E_except_after_C | I before E except after C | The phrase "I before E, except after C" is a
widely known mnemonic which is supposed to help when spelling English words.
Task
Using the word list from http://wiki.puzzlers.org/pub/wordlists/unixdict.txt,
check if the two sub-clauses of the phrase are plausible individually:
"I before E when not pre... | #Wren | Wren | import "io" for File
import "/pattern" for Pattern
import "/fmt" for Fmt
var yesNo = Fn.new { |b| (b) ? "yes" : "no" }
var plausRatio = 2
var count1 = 0 // [^c]ie
var count2 = 0 // [^c]ei
var count3 = 0 // cie
var count4 = 0 // cei
var count5 = 0 // ^ie
var count6 = 0 // ^ei
var p1 = Pattern.new("^cie")
v... |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #Pop11 | Pop11 | lvars s = '123456789012123456789999999999';
(strnumber(s) + 1) >< '' -> s; |
http://rosettacode.org/wiki/Increment_a_numerical_string | Increment a numerical string | Task
Increment a numerical string.
| #PowerShell | PowerShell | $s = "12345"
$t = [string] ([int] $s + 1) |
http://rosettacode.org/wiki/Integer_comparison | Integer comparison |
Basic Data Operation
This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:
Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |... | #NetRexx | NetRexx | /* NetRexx */
options replace format comments java crossref symbols nobinary
numL = 0
numR = 0
loop label running forever
say 'Provide two integers [or anything else to stop]:'
parse ask numL numR .
if \numL.datatype('w') | \numR.datatype('w') then leave running
if numL < numR then say numL 'is less than' num... |
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 |... | #NewLISP | NewLISP |
(print "Please enter the first number: ")
(set 'A (int (read-line)))
(print "Please enter the second number: ")
(set 'B (int (read-line)))
(println
"The first one is "
(cond
((> A B) "greater than")
((= A B) "equal to")
(true "less than"))
" the second.")
|
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Maple | Maple |
content := URL:-Get( "https://www.google.ca/" );
|
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language |
content=Import["https://sourceforge.net", "HTML"]
|
http://rosettacode.org/wiki/HTTPS | HTTPS | Task
Send a GET request to obtain the resource located at the URL "https://www.w3.org/", then print it to the console.
Checking the host certificate for validity is recommended.
Do not authenticate. That is the subject of other tasks.
Readers may wish to contrast with the HTTP Request task, and also the task on HTT... | #MATLAB_.2F_Octave | MATLAB / Octave | s=urlread('https://sourceforge.net/') |
http://rosettacode.org/wiki/HTTP | HTTP | Task
Access and print a URL's content (the located resource) to the console.
There is a separate task for HTTPS Requests.
| #ALGOL_68 | ALGOL 68 |
STRING domain="rosettacode.org";
STRING page="wiki/Main_Page";
STRING re success="^HTTP/[0-9.]* 200";
STRING re result description="^HTTP/[0-9.]* [0-9]+ [a-zA-Z ]*";
STRING re doctype ="\s\s<!DOCTYPE html PUBLIC ""[^>]+"">\s+";
PROC html page = (REF STRING page) BOOL: (
BOOL out=grep in string(re success, pa... |
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation | Horner's rule for polynomial evaluation | A fast scheme for evaluating a polynomial such as:
−
19
+
7
x
−
4
x
2
+
6
x
3
{\displaystyle -19+7x-4x^{2}+6x^{3}\,}
when
x
=
3
{\displaystyle x=3\;}
.
is to arrange the computation as follows:
(
(
(
(
0
)
x
+
6
)
x
+
(
−
4
)
)
x
+
7
)
x
+
(
−
19
)
{\displaystyle ((((0)x+6)x+(-4))x... | #ALGOL_68 | ALGOL 68 | PROC horner = ([]REAL c, REAL x)REAL :
(
REAL res := 0.0;
FOR i FROM UPB c BY -1 TO LWB c DO
res := res * x + c[i]
OD;
res
);
main:(
[4]REAL coeffs := (-19.0, 7.0, -4.0, 6.0);
print( horner(coeffs, 3.0) )
) |
http://rosettacode.org/wiki/Horner%27s_rule_for_polynomial_evaluation | Horner's rule for polynomial evaluation | A fast scheme for evaluating a polynomial such as:
−
19
+
7
x
−
4
x
2
+
6
x
3
{\displaystyle -19+7x-4x^{2}+6x^{3}\,}
when
x
=
3
{\displaystyle x=3\;}
.
is to arrange the computation as follows:
(
(
(
(
0
)
x
+
6
)
x
+
(
−
4
)
)
x
+
7
)
x
+
(
−
19
)
{\displaystyle ((((0)x+6)x+(-4))x... | #ALGOL_W | ALGOL W | begin
% Horner's rule for polynominal evaluation %
% returns the value of the polynominal defined by coefficients, %
% at the point x. The number of coefficients must be in ub %
% the coefficients should be in order with x^0 first, x^n last %
re... |
http://rosettacode.org/wiki/Home_primes | Home primes |
This page uses content from Wikipedia. The original article was at Home prime. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
In number theory, the home prime HP(n) of an integer n greater than 1 is... | #Go | Go | package main
import (
"fmt"
"math/big"
"rcu"
"sort"
)
var zero = new(big.Int)
var one = big.NewInt(1)
var two = big.NewInt(2)
var three = big.NewInt(3)
var four = big.NewInt(4)
var five = big.NewInt(5)
var six = big.NewInt(6)
// simple wheel based prime factors routine for BigInt
func primeFactors... |
http://rosettacode.org/wiki/Horizontal_sundial_calculations | Horizontal sundial calculations | Task
Create a program that calculates the hour, sun hour angle, dial hour line angle from 6am to 6pm for an operator entered location.
For example, the user is prompted for a location and inputs the latitude and longitude 4°57′S 150°30′W (4.95°S 150.5°W of Jules Verne's Lincoln Island, aka Ernest Legouve Reef), wit... | #AutoHotkey | AutoHotkey | DllCall("AllocConsole") ; Open a console window for this application
Pi := 4*ATan(1)
,Degrees := Pi/180
FileAppend, Enter Latitude: , CONOUT$ ; write to stdout
FileReadLine, latitude, CONIN$, 1 ; read from stdin
FileAppend, Enter Longitude: , CONOUT$
FileReadLine, longitude, CONIN$, 1
FileAppend, Enter Lega... |
http://rosettacode.org/wiki/Huffman_coding | Huffman coding | Huffman encoding is a way to assign binary codes to symbols that reduces the overall number of bits used to encode a typical string of those symbols.
For example, if you use letters as symbols and have details of the frequency of occurrence of those letters in typical strings, then you could just encode each letter wi... | #Eiffel | Eiffel |
class HUFFMAN_NODE[T -> COMPARABLE]
inherit
COMPARABLE
redefine
three_way_comparison
end
create
leaf_node, inner_node
feature {NONE}
leaf_node (a_probability: REAL_64; a_value: T)
do
probability := a_probability
value := a_value
is_leaf := true
left := void
right := void
parent := void
end
i... |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #Groovy | Groovy | println "word size: ${System.getProperty('sun.arch.data.model')}"
println "endianness: ${System.getProperty('sun.cpu.endian')}" |
http://rosettacode.org/wiki/Host_introspection | Host introspection | Print the word size and endianness of the host machine.
See also: Variable size/Get
| #Haskell | Haskell | import Data.Bits
import ADNS.Endian -- http://hackage.haskell.org/package/hsdns
main = do
putStrLn $ "Word size: " ++ bitsize
putStrLn $ "Endianness: " ++ show endian
where
bitsize = show $ bitSize (undefined :: Int) |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Go | Go | package main
import (
"fmt"
"os"
)
func main() {
fmt.Println(os.Hostname())
} |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Groovy | Groovy | println InetAddress.localHost.hostName |
http://rosettacode.org/wiki/Hostname | Hostname | Task
Find the name of the host on which the routine is running.
| #Harbour | Harbour | ? NetName() |
http://rosettacode.org/wiki/IBAN | IBAN |
This page uses content from Wikipedia. The original article was at IBAN. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance)
The International Bank Account Number (IBAN) is an internationally agree... | #VBA | VBA | Public nations As New Collection
Private Sub init()
nations.Add 24, "AD"
nations.Add 21, "CH"
nations.Add 22, "GB"
nations.Add 24, "SA"
nations.Add 20, "XK"
End Sub
Private Function mod97(ByVal c As String) As Integer
Dim n As Long
n = Val(Mid(c, 1, 9))
c = Mid(c, 10, Len(c) - 9)
n... |
http://rosettacode.org/wiki/Hough_transform | Hough transform | Task
Implement the Hough transform, which is used as part of feature extraction with digital images.
It is a tool that makes it far easier to identify straight lines in the source image, whatever their orientation.
The transform maps each point in the target image,
(
ρ
,
θ
)
{\displaystyle (\rho ,\theta )}
, ... | #Racket | Racket | use GD;
my $filename = 'pentagon.ppm';
my $in = open($filename, :r, :enc<iso-8859-1>);
my ($type, $dim, $depth) = $in.lines[^3];
my ($xsize,$ysize) = split ' ', $dim;
my ($width, $height) = 460, 360;
my $image = GD::Image.new($width, $height);
my @canvas = [255 xx $width] xx $height;
my $rmax = sqrt($xsize**2 +... |
http://rosettacode.org/wiki/Identity_matrix | Identity matrix | Task
Build an identity matrix of a size known at run-time.
An identity matrix is a square matrix of size n × n,
where the diagonal elements are all 1s (ones),
and all the other elements are all 0s (zeroes).
I
n
=
[
1
0
0
⋯
0
0
1
0
⋯
0
0
0
1
⋯
0
⋮
⋮
⋮
⋱
... | #NetRexx | NetRexx | /* NetRexx ************************************************************
* show identity matrix of size n
* I consider m[i,j] to represent the matrix
* 09.07.2013 Walter Pachl (translated from REXX Version 2)
**********************************************************************/
options replace format comments java cro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.