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/The_sieve_of_Sundaram | The sieve of Sundaram | The sieve of Eratosthenes: you've been there; done that; have the T-shirt. The sieve of Eratosthenes was ancient history when Euclid was a schoolboy. You are ready for something less than 3000 years old. You are ready for The sieve of Sundaram.
Starting with the ordered set of +ve integers, mark every third starting a... | #Phix | Phix | with javascript_semantics
function sos(integer n)
if n<3 then return {} end if
integer r = floor(sqrt(n)),
k = floor((n-3)/2)+1,
l = floor((r-3)/2)+1
sequence primes = {},
marked = repeat(false,k)
for i=1 to l do
integer p = 2*i+1,
s = (p*p-1)... |
http://rosettacode.org/wiki/The_sieve_of_Sundaram | The sieve of Sundaram | The sieve of Eratosthenes: you've been there; done that; have the T-shirt. The sieve of Eratosthenes was ancient history when Euclid was a schoolboy. You are ready for something less than 3000 years old. You are ready for The sieve of Sundaram.
Starting with the ordered set of +ve integers, mark every third starting a... | #Python | Python | from numpy import log
def sieve_of_Sundaram(nth, print_all=True):
"""
The sieve of Sundaram is a simple deterministic algorithm for finding all the
prime numbers up to a specified integer. This function is modified from the
Wikipedia entry wiki/Sieve_of_Sundaram, to give primes to their nth rather
... |
http://rosettacode.org/wiki/The_sieve_of_Sundaram | The sieve of Sundaram | The sieve of Eratosthenes: you've been there; done that; have the T-shirt. The sieve of Eratosthenes was ancient history when Euclid was a schoolboy. You are ready for something less than 3000 years old. You are ready for The sieve of Sundaram.
Starting with the ordered set of +ve integers, mark every third starting a... | #Racket | Racket | #lang racket
(define (make-sieve-as-set limit)
(let ((marked (for/mutable-set ((i limit)) (add1 i))))
(let loop ((start 4) (step 3))
(cond [(>= start limit) marked]
[else (for ((i (in-range start limit step))) (set-remove! marked i))
(loop (+ start 3) (+ step 2))]))
(defi... |
http://rosettacode.org/wiki/The_sieve_of_Sundaram | The sieve of Sundaram | The sieve of Eratosthenes: you've been there; done that; have the T-shirt. The sieve of Eratosthenes was ancient history when Euclid was a schoolboy. You are ready for something less than 3000 years old. You are ready for The sieve of Sundaram.
Starting with the ordered set of +ve integers, mark every third starting a... | #Raku | Raku | my $nth = 1_000_000;
my $k = Int.new: 2.4 * $nth * log($nth) / 2;
my int @sieve;
@sieve[$k] = 0;
hyper for 1 .. $k -> \i {
my int $j = i;
while (my int $l = i + $j + 2 * i * $j) < $k {
@sieve[$l] = 1;
$j = $j + 1;
}
}
@sieve[0] = 1;
say "First 100 Sundaram primes:";
say @sieve.kv... |
http://rosettacode.org/wiki/The_sieve_of_Sundaram | The sieve of Sundaram | The sieve of Eratosthenes: you've been there; done that; have the T-shirt. The sieve of Eratosthenes was ancient history when Euclid was a schoolboy. You are ready for something less than 3000 years old. You are ready for The sieve of Sundaram.
Starting with the ordered set of +ve integers, mark every third starting a... | #REXX | REXX | /*REXX program finds & displays N Sundaram primes, or displays the Nth Sundaram prime.*/
parse arg n cols . /*get optional number of primes to find*/
if n=='' | n=="," then n= 100 /*Not specified? Then assume default.*/
if cols=='' | cols=="," then cols= 10 ... |
http://rosettacode.org/wiki/The_sieve_of_Sundaram | The sieve of Sundaram | The sieve of Eratosthenes: you've been there; done that; have the T-shirt. The sieve of Eratosthenes was ancient history when Euclid was a schoolboy. You are ready for something less than 3000 years old. You are ready for The sieve of Sundaram.
Starting with the ordered set of +ve integers, mark every third starting a... | #Ruby | Ruby | def sieve_of_sundaram(upto)
n = (2.4 * upto * Math.log(upto)) / 2
k = (n - 3) / 2 + 1
bools = [true] * k
(0..(Integer.sqrt(n) - 3) / 2 + 1).each do |i|
p = 2*i + 3
s = (p*p - 3) / 2
(s..k).step(p){|j| bools[j] = false}
end
bools.filter_map.each_with_index {|b, i| (i + 1) * 2 + 1 if b }
end
p s... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #11l | 11l | F thieleInterpolator(x, y)
V ρ = enumerate(y).map((i, yi) -> [yi] * (@y.len - i))
L(i) 0 .< ρ.len - 1
ρ[i][1] = (x[i] - x[i + 1]) / (ρ[i][0] - ρ[i + 1][0])
L(i) 2 .< ρ.len
L(j) 0 .< ρ.len - i
ρ[j][i] = (x[j] - x[j + i]) / (ρ[j][i - 1] - ρ[j + 1][i - 1]) + ρ[j + 1][i - 2]
V ρ0 = ρ[0]
... |
http://rosettacode.org/wiki/The_sieve_of_Sundaram | The sieve of Sundaram | The sieve of Eratosthenes: you've been there; done that; have the T-shirt. The sieve of Eratosthenes was ancient history when Euclid was a schoolboy. You are ready for something less than 3000 years old. You are ready for The sieve of Sundaram.
Starting with the ordered set of +ve integers, mark every third starting a... | #Wren | Wren | import "/fmt" for Fmt
import "/seq" for Lst
var sos = Fn.new { |n|
if (n < 3) return []
var primes = []
var k = ((n-3)/2).floor + 1
var marked = List.filled(k, true)
var limit = ((n.sqrt.floor - 3)/2).floor + 1
limit = limit.max(0)
for (i in 0...limit) {
var p = 2*i + 3
var... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Ada | Ada | with Ada.Numerics.Generic_Real_Arrays;
generic
type Real is digits <>;
package Thiele is
package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (Real);
subtype Real_Array is Real_Arrays.Real_Vector;
type Thiele_Interpolation (Length : Natural) is private;
function Create (X, Y : Real_Array) re... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #ALGOL_68 | ALGOL 68 | PROC raise exception = ([]STRING msg)VOID: ( putf(stand error,("Exception:", $" "g$, msg, $l$)); stop );
# The MODE of lx and ly here should really be a UNION of "something REAL",
"something COMPLex", and "something SYMBOLIC" ... #
PROC thiele=([]REAL lx,ly, REAL x) REAL:
BEGIN
[]REAL xx=lx[@1],yy=ly[@1];
INT n... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #C | C | #include <stdio.h>
#include <string.h>
#include <math.h>
#define N 32
#define N2 (N * (N - 1) / 2)
#define STEP .05
double xval[N], t_sin[N], t_cos[N], t_tan[N];
/* rho tables, layout:
rho_{n-1}(x0)
rho_{n-2}(x0), rho_{n-1}(x1),
....
rho_0(x0), rho_0(x1), ... rho_0(x_{n-1})
rho_i row starts at index (n - 1... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #C.2B.2B | C++ | #include <cmath>
#include <iostream>
#include <iomanip>
#include <string.h>
constexpr unsigned int N = 32u;
double xval[N], t_sin[N], t_cos[N], t_tan[N];
constexpr unsigned int N2 = N * (N - 1u) / 2u;
double r_sin[N2], r_cos[N2], r_tan[N2];
double ρ(double *x, double *y, double *r, int i, int n) {
if (n < 0)
... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Common_Lisp | Common Lisp | ;; 256 is heavy overkill, but hey, we memoized
(defparameter *thiele-length* 256)
(defparameter *rho-cache* (make-hash-table :test #'equal))
(defmacro make-thele-func (f name xx0 xx1)
(let ((xv (gensym)) (yv (gensym))
(x0 (gensym)) (x1 (gensym)))
`(let* ((,xv (make-array (1+ *thiele-length*)))
(,yv (make-... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #D | D | import std.stdio, std.range, std.array, std.algorithm, std.math;
struct Domain {
const real b, e, s;
auto range() const pure /*nothrow*/ @safe /*@nogc*/ {
return iota(b, e + s, s);
}
}
real eval0(alias RY, alias X, alias Y)(in real x) pure nothrow @safe @nogc {
real a = 0.0L;
foreach_r... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Go | Go | package main
import (
"fmt"
"math"
)
func main() {
// task 1: build 32 row trig table
const nn = 32
const step = .05
xVal := make([]float64, nn)
tSin := make([]float64, nn)
tCos := make([]float64, nn)
tTan := make([]float64, nn)
for i := range xVal {
xVal[i] = float64... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Haskell | Haskell | thiele :: [Double] -> [Double] -> Double -> Double
thiele xs ys = f rho1 (tail xs)
where
f _ [] _ = 1
f r@(r0:r1:r2:rs) (x:xs) v = r2 - r0 + (v - x) / f (tail r) xs v
rho1 = (!! 1) . (++ [0]) <$> rho
rho = repeat 0 : repeat 0 : ys : rnext (tail rho) xs (tail xs)
where
rnext _ _ [] = []
... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #J | J |
span =: {. - {: NB. head - tail
spans =: span\ NB. apply span to successive infixes
|
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Java | Java | import static java.lang.Math.*;
public class Test {
final static int N = 32;
final static int N2 = (N * (N - 1) / 2);
final static double STEP = 0.05;
static double[] xval = new double[N];
static double[] t_sin = new double[N];
static double[] t_cos = new double[N];
static double[] t_tan... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Julia | Julia | const N = 256
const N2 = N * div(N - 1, 2)
const step = 0.01
const xval_table = zeros(Float64, N)
const tsin_table = zeros(Float64, N)
const tcos_table = zeros(Float64, N)
const ttan_table = zeros(Float64, N)
const rsin_cache = Dict{Float64, Float64}()
const rcos_cache = Dict{Float64, Float64}()
const rtan_cache = Dict... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Kotlin | Kotlin | // version 1.1.2
const val N = 32
const val N2 = N * (N - 1) / 2
const val STEP = 0.05
val xval = DoubleArray(N)
val tsin = DoubleArray(N)
val tcos = DoubleArray(N)
val ttan = DoubleArray(N)
val rsin = DoubleArray(N2) { Double.NaN }
val rcos = DoubleArray(N2) { Double.NaN }
val rtan = DoubleArray(N2) { Double.NaN }... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | num = 32;
num2 = num (num - 1)/2;
step = 0.05;
ClearAll[\[Rho], Thiele]
\[Rho][x_List, y_List, i_Integer, n_Integer] := Module[{idx},
If[n < 0,
0
,
If[n == 0,
y[[i + 1]]
,
idx = (num - 1 - n) (num - n)/2 + i + 1;
If[r[[idx]] === Null,
r[[idx]] = (x[[1 + i]] -
x[[1 + i + n]])/... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Nim | Nim | import strformat
import math
const N = 32
const N2 = N * (N - 1) div 2
const STEP = 0.05
var xval = newSeq[float](N)
var tsin = newSeq[float](N)
var tcos = newSeq[float](N)
var ttan = newSeq[float](N)
var rsin = newSeq[float](N2)
var rcos = newSeq[float](N2)
var rtan = newSeq[float](N2)
proc rho(x, y: openArray[f... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #OCaml | OCaml | let xv, fv = fst, snd
let rec rdiff a l r =
if l > r then 0.0 else
if l = r then fv a.(l) else
if l+1 = r then (xv a.(l) -. xv a.(r)) /. (fv a.(l) -. fv a.(r)) else
(xv a.(l) -. xv a.(r)) /. (rdiff a l (r-1) -. rdiff a (l+1) r) +. rdiff a (l+1) (r-1)
let rec thiele x a a0 k n =
if k = n then 1.0 else... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Perl | Perl | use strict;
use warnings;
use feature 'say';
use Math::Trig;
use utf8;
sub thiele {
my($x, $y) = @_;
my @ρ;
push @ρ, [($$y[$_]) x (@$y-$_)] for 0 .. @$y-1;
for my $i (0 .. @ρ - 2) {
$ρ[$i][1] = (($$x[$i] - $$x[$i+1]) / ($ρ[$i][0] - $ρ[$i+1][0]))
}
for my $i (2 .. @ρ - 2) {
fo... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #11l | 11l | F print_verse(n)
V l = [String(‘b’), ‘f’, ‘m’]
V s = n[1..]
V? i = l.find(n[0].lowercase())
I i != N
l[i] = ‘’
E I n[0] C (‘A’, ‘E’, ‘I’, ‘O’, ‘U’)
s = n.lowercase()
print("#., #., bo-#.#.\nBanana-fana fo-#.#.\nFee-fi-mo-#.#.\n#.!\n".format(n, n, l[0], s, l[1], s, l[2], s, n))
L(n) [‘Gar... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Phix | Phix | constant N = 32,
N2 = (N * (N - 1) / 2),
STEP = 0.05
constant inf = 1e300*1e300,
nan = -(inf/inf)
sequence {xval, t_sin, t_cos, t_tan} = repeat(repeat(0,N),4)
for i=1 to N do
xval[i] = (i-1) * STEP
t_sin[i] = sin(xval[i])
t_cos[i] = cos(xval[i])
t_tan[i] = t_sin[i] / t_c... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #Ada | Ada | with Ada.Characters.Handling;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
procedure The_Name_Game
is
package ACH renames Ada.Characters.Handling;
package ASU renames Ada.Strings.Unbounded;
function "+"(input : in String) return ASU.Unbounded_String renames ASU.To_Unbounded_String;
function "+"(input : i... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #PicoLisp | PicoLisp | (scl 17)
(load "@lib/math.l")
(setq
*X-Table (range 0.0 1.55 0.05)
*SinTable (mapcar sin *X-Table)
*CosTable (mapcar cos *X-Table)
*TanTable (mapcar tan *X-Table)
*TrigRows (length *X-Table) )
(let N2 (>> 1 (* *TrigRows (dec *TrigRows)))
(setq
*InvSinTable (need N2)
*InvCosTable (need ... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #11l | 11l | V debug = 0B
V datePat = re:‘\d{4}-\d{2}-\d{2}’
V valuPat = re:‘[-+]?\d+\.\d+’
V statPat = re:‘-?\d+’
V totalLines = 0
Set[String] dupdate
Set[String] badform
Set[String] badlen
V badreading = 0
Set[String] datestamps
L(line) File(‘readings.txt’).read().rtrim("\n").split("\n")
totalLines++
V fields = line.split... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #ALGOL_68 | ALGOL 68 |
main:(
PROC print lyrics = (STRING name) VOID:
BEGIN
PROC change name = (STRING name, CHAR initial) STRING:
BEGIN
CHAR lower first = to lower(name[1]);
IF char in string(lower first, NIL, "aeiou") THEN
lower first + name[2:]
ELIF lower first = initial THEN... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #PowerShell | PowerShell | Function Reciprocal-Difference( [Double[][]] $function )
{
$rho=@()
$rho+=0
$funcl = $function.length
if( $funcl -gt 0 )
{
-2..($funcl-1) | ForEach-Object {
$i=$_
#Write-Host "$($i+1) - $($rho[$i+1]) - $($rho[$i+1].GetType())"
$rho[$i+2] = $( 0..($funcl-$i... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #Ada | Ada | with Ada.Calendar; use Ada.Calendar;
with Ada.Text_IO; use Ada.Text_IO;
with Strings_Edit; use Strings_Edit;
with Strings_Edit.Floats; use Strings_Edit.Floats;
with Strings_Edit.Integers; use Strings_Edit.Integers;
with Generic_Map;
procedure Data_Munging_2 is
package Time_To_L... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #AutoHotkey | AutoHotkey | for i, x in StrSplit("Gary,Earl,Billy,Felix,Mary", ","){
BFM := false
if (SubStr(x, 1, 1) ~= "i)^[AEIOU]") ; Vowel
y := x
else if (SubStr(x, 1, 1) ~= "i)^[BFM]") ; BFM
y := SubStr(x,2), BFM := true
else
y := SubStr(x,2)
StringLower, y, y
output := X ", " X ", bo-" (SubStr(x,1,1)="b"&&BFM ? "" : "b") Y
. ... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Python | Python | #!/usr/bin/env python3
import math
def thieleInterpolator(x, y):
ρ = [[yi]*(len(y)-i) for i, yi in enumerate(y)]
for i in range(len(ρ)-1):
ρ[i][1] = (x[i] - x[i+1]) / (ρ[i][0] - ρ[i+1][0])
for i in range(2, len(ρ)):
for j in range(len(ρ)-i):
ρ[j][i] = (x[j]-x[j+i]) / (ρ[j][i-... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #Aime | Aime | check_format(list l)
{
integer i;
text s;
if (~l != 49) {
error("bad field count");
}
s = l[0];
if (match("????-??-??", s)) {
error("bad date format");
}
l[0] = s.delete(7).delete(4).atoi;
i = 1;
while (i < 49) {
atof(l[i]);
i += 1;
l... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #AWK | AWK |
# syntax: GAWK -f THE_NAME_GAME.AWK
BEGIN {
n = split("gary,earl,billy,felix,mary,shirley",arr,",")
for (i=1; i<=n; i++) {
print_verse(arr[i])
}
exit(0)
}
function print_verse(name, c,x,y) {
x = toupper(substr(name,1,1)) tolower(substr(name,2))
y = (x ~ /^[AEIOU]/) ? tolower(x) : substr... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #11l | 11l | [Char = String] CH2NUM
L(chars) ‘abc def ghi jkl mno pqrs tuv wxyz’.split(‘ ’)
V num = L.index + 2
L(ch) chars
CH2NUM[ch] = String(num)
F mapnum2words(words)
DefaultDict[String, [String]] number2words
V reject = 0
L(word) words
X.try
number2words[word.map(ch -> :CH2NUM[ch]).join(‘’... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Racket | Racket |
#lang racket
(define xs (for/vector ([x (in-range 0.0 1.6 0.05)]) x))
(define (x i) (vector-ref xs i))
(define-syntax define-table
(syntax-rules ()
[(_ f tf rf if)
(begin (define tab (for/vector ([x xs]) (f x)))
(define (tf n) (vector-ref tab n))
(define cache (make-vector (/ (*... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #AutoHotkey | AutoHotkey | ; Author: AlephX Aug 17 2011
data = %A_scriptdir%\readings.txt
Loop, Read, %data%
{
Lines := A_Index
StringReplace, dummy, A_LoopReadLine, %A_Tab%,, All UseErrorLevel
Loop, parse, A_LoopReadLine, %A_Tab%
{
wrong := 0
if A_index = 1
{
Date := A_LoopField
if (Date == OldDate)
{
Wrong... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #BASIC256 | BASIC256 | subroutine TheGameName(nombre)
x = lower(nombre)
x = upper(mid(x,1,1)) + (mid(x,2,length(x)-1))
x0 = upper(mid(x,1,1))
if x0 = "A" or x0 = "e" or x0 = "I" or x0 = "O" or x0 = "U" then
y = lower(x)
else
y = mid(x,2,length(x)-1)
end If
b = "b" + y
f = "f" + y
m = "m" + y
begin case
case x0 = "B"
... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #C | C | #include <stdio.h>
#include <string.h>
void print_verse(const char *name) {
char *x, *y;
int b = 1, f = 1, m = 1, i = 1;
/* ensure name is in title-case */
x = strdup(name);
x[0] = toupper(x[0]);
for (; x[i]; ++i) x[i] = tolower(x[i]);
if (strchr("AEIOU", x[0])) {
y = str... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #ALGOL_68 | ALGOL 68 | # find textonyms in a list of words #
# use the associative array in the Associate array/iteration task #
PR read "aArray.a68" PR
# returns the number of occurances of ch in text #
PROC count = ( STRING text, CHAR ch )INT:
BEGIN
INT result := 0;
FOR c FROM LWB text TO UPB text DO IF text[ c... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Raku | Raku | # reciprocal difference:
multi sub ρ(&f, @x where * < 1) { 0 } # Identity
multi sub ρ(&f, @x where * == 1) { &f(@x[0]) }
multi sub ρ(&f, @x where * > 1) {
( @x[0] - @x[* - 1] ) # ( x - x[n] )
/ (ρ(&f, @x[^(@x - 1)]) # / ( ρ[n-1](x[0], ..., x[n-1])
- ρ(&f, @x[1..^@x]) ) # - ρ[n-1](x[1], ..., ... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #AWK | AWK | bash$ awk '/[eE]/' readings.txt
bash$ |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #C.23 | C# | using System;
using System.Collections.Generic;
using System.Text;
namespace TheNameGame {
class Program {
static void PrintVerse(string name) {
StringBuilder sb = new StringBuilder(name.ToLower());
sb[0] = Char.ToUpper(sb[0]);
string x = sb.ToString();
stri... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #C | C | #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
char text_char(char c) {
switch (c) {
case 'a': case 'b': case 'c':
return '2';
case 'd': case 'e': case 'f':
return '3';
case 'g': case 'h': case 'i':
return '4';
case 'j': case 'k': case 'l':
... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #11l | 11l | V out = 0
V max_out = -1
[String] max_times
L(job) File(‘mlijobs.txt’).read_lines()
out += I ‘OUT’ C job {1} E -1
I out > max_out
max_out = out
max_times.clear()
I out == max_out
max_times.append(job.split(‘ ’)[3])
print(‘Maximum simultaneous license use is #. at the following times:’.forma... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Rust | Rust |
const N: usize = 32;
const STEP: f64 = 0.05;
fn main() {
let x: Vec<f64> = (0..N).map(|i| i as f64 * STEP).collect();
let sin = x.iter().map(|x| x.sin()).collect::<Vec<_>>();
let cos = x.iter().map(|x| x.cos()).collect::<Vec<_>>();
let tan = x.iter().map(|x| x.tan()).collect::<Vec<_>>();
print... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Sidef | Sidef | func thiele(x, y) {
var ρ = {|i| [y[i]]*(y.len-i) }.map(^y)
for i in ^(ρ.end) {
ρ[i][1] = ((x[i] - x[i+1]) / (ρ[i][0] - ρ[i+1][0]))
}
for i (2 .. ρ.end) {
for j (0 .. ρ.end-i) {
ρ[j][i] = (((x[j]-x[j+i]) / (ρ[j][i-1]-ρ[j+1][i-1])) + ρ[j+1][i-2])
}
}
var ρ0... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #C | C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
typedef struct { const char *s; int ln, bad; } rec_t;
int cmp_rec(const void *aa, const void *bb)
{
const rec_t *a = aa, *b = bb;
return a->s == b->s ? 0 : !a->s ? 1 : !b->s... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #C.2B.2B | C++ | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
static void printVerse(const std::string& name) {
std::string x = name;
std::transform(x.begin(), x.end(), x.begin(), ::tolower);
x[0] = toupper(x[0]);
std::string y;
switch (x[0]) {
case 'A':
case 'E':
case... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #C.2B.2B | C++ | #include <fstream>
#include <iostream>
#include <unordered_map>
#include <vector>
struct Textonym_Checker {
private:
int total;
int elements;
int textonyms;
int max_found;
std::vector<std::string> max_strings;
std::unordered_map<std::string, std::vector<std::string>> values;
int get_mapp... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #Ada | Ada | -- licenselist.adb --
-- run under GPS 4.3-5 (Sidux/Debian)
-- process rosetta.org text_processing/3 example
-- uses linked-list to hold times
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Strings.Unbounded,
Ada.Strings.Unbounded.Text_IO,
Ada.Containers.Doubly_Linked_Lists;
use Ada.Text_IO, Ada.Integer_Text_IO,
... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Swift | Swift | let N = 32
let N2 = N * (N - 1) / 2
let step = 0.05
var xval = [Double](repeating: 0, count: N)
var tsin = [Double](repeating: 0, count: N)
var tcos = [Double](repeating: 0, count: N)
var ttan = [Double](repeating: 0, count: N)
var rsin = [Double](repeating: .nan, count: N2)
var rcos = [Double](repeating: .nan, count... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #C.23 | C# | using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO;
namespace TextProc2
{
class Program
{
static void Main(string[] args)
{
Regex multiWhite = new Regex(@"\s+");
Regex dateEx = new Regex(@"^\d{4}-\d{2}-\d{2}$");
... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #Commodore_BASIC | Commodore BASIC | 1 rem name game
2 rem rosetta code
5 dim cn$(3),bl$(3,32):gosub 1000
10 print chr$(147);chr$(14);"Name Game":print
15 cn$(0)="":cn$(1)="b":cn$(2)="f":cn$(3)="m"
20 print chr$(147);chr$(14);"Name Game":print:input "Enter any name";n$
25 rem ensure first letter is lowercase
30 n$=chr$(asc(n$) and 95)+right$(n$,len(n$)-... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #Clojure | Clojure |
(def table
{\a 2 \b 2 \c 2 \A 2 \B 2 \C 2
\d 3 \e 3 \f 3 \D 3 \E 3 \F 3
\g 4 \h 4 \i 4 \G 4 \H 4 \I 4
\j 5 \k 5 \l 5 \J 5 \K 5 \L 5
\m 6 \n 6 \o 6 \M 6 \N 6 \O 6
\p 7 \q 7 \r 7 \s 7 \P 7 \Q 7 \R 7 \S 7
\t 8 \u 8 \v 8 \T 8 \U 8 \V 8
\w 9 \x 9 \y 9 \z 9 \W 9 ... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #ALGOL_68 | ALGOL 68 | PROC report = (REF FILE file in)INT: (
MODE TIME = [19]CHAR;
STRUCT ([3]CHAR inout, TIME time, INT jobnum) record;
FORMAT record fmt = $"License "g" @ "g" for job "g(0)l$;
FLEX[1]TIME max time;
INT lic out := 0, max out := LWB max time-1, max count := LWB max time-1;
BOOL file in ended := FALSE;
on ... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Tcl | Tcl | #
### Create a thiele-interpretation function with the given name that interpolates
### off the given table.
#
proc thiele {name : X -> F} {
# Sanity check
if {[llength $X] != [llength $F]} {
error "unequal length lists supplied: [llength $X] != [llength $F]"
}
#
### Compute the table of reciproc... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #C.2B.2B | C++ | #include <boost/regex.hpp>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <cstdlib>
#include <algorithm>
using namespace std ;
boost::regex e ( "\\s+" ) ;
int main( int argc , char *argv[ ] ) {
ifstream infile( argv[ 1 ] ) ;
vector<string> duplicates ;
... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #D | D | import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.uni;
void printVerse(string name) {
auto sb = name.map!toLower.array;
sb[0] = sb[0].toUpper;
string x = sb.to!string;
string y;
switch(sb[0]) {
case 'A':
case 'E':
case 'I':
case... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #D | D | void main() {
import std.stdio, std.string, std.range, std.algorithm, std.ascii;
immutable src = "unixdict.txt";
const words = src.File.byLineCopy.map!strip.filter!(w => w.all!isAlpha).array;
immutable table = makeTrans("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #APL | APL | ⍝ Copy/paste file's contents into TXT (easiest), or TXT ← ⎕NREAD
I ← TXT[;8+⎕IO]
D ← TXT[;⎕IO+14+⍳19]
lu ← +\ ¯1 * 'OI' ⍳ I
mx ← (⎕IO+⍳⍴lu)/⍨lu= max ← ⌈/ lu
⎕ ← 'Maximum simultaneous license use is ' , ' at the following times:' ,⍨ ⍕max ⋄ ⎕←D[mx;] |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #Wren | Wren | import "/fmt" for Fmt
var N = 32
var N2 = N * (N - 1) / 2
var STEP = 0.05
var xval = List.filled(N, 0.0)
var tsin = List.filled(N, 0.0)
var tcos = List.filled(N, 0.0)
var ttan = List.filled(N, 0.0)
var rsin = List.filled(N2, 0/0)
var rcos = List.filled(N2, 0/0)
var rtan = List.filled(N2, 0/0)
var rho
rho = Fn.ne... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #Clojure | Clojure |
(defn parse-line [s]
(let [[date & data-toks] (str/split s #"\s+")
data-fields (map read-string data-toks)
valid-date? (fn [s] (re-find #"\d{4}-\d{2}-\d{2}" s))
valid-line? (and (valid-date? date)
(= 48 (count data-toks))
(every? number? data... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #Dyalect | Dyalect | func printVerse(name) {
let x = name[..1].Upper() + name[1..].Lower();
let y = "AEIOU".IndexOf(x[0]) > -1 ? x.Lower() : x[1..]
let b = x[0] is 'B' ? y : "b" + y
let f = x[0] is 'F' ? y : "f" + y
let m = x[0] is 'M' ? y : "m" + y
print("\(x), \(x), bo-\(b)")
print("Banana-fana fo-\(f)")
... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #F.23 | F# |
// The Name Game. Nigel Galloway: March 28th., 2018
let fN g =
let fG α β γ = printfn "%s, %s, bo-%s\nBanana-fana fo-%s\nFee-fi-mo-%s\n%s!" g g α β γ g
match g.ToLower().[0] with
|'a'|'e'|'i'|'o'|'u' as n -> fG ("b"+(string n)+g.[1..]) ("f"+(string n)+g.[1..]) ("m"+(string n)+g.[1..])
|'b' ... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #Delphi | Delphi |
program Textonyms;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
System.Classes,
System.Generics.Collections,
System.Character;
const
TEXTONYM_MAP = '22233344455566677778889999';
type
TextonymsChecker = class
private
Total, Elements, Textonyms, MaxFound: Integer;
MaxStrings: TList<string>;
... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #AutoHotkey | AutoHotkey |
IfNotExist, mlijobs.txt
UrlDownloadToFile, http://rosettacode.org/mlijobs.txt, mlijobs.txt
out := 0, max_out := -1, max_times := ""
Loop, Read, mlijobs.txt
{
If InStr(A_LoopReadLine, "OUT")
out++
Else
out--
If (out > max_out)
max_out := out, max_times := ""
If (out = max_out)
{
StringS... |
http://rosettacode.org/wiki/Thiele%27s_interpolation_formula | Thiele's interpolation formula |
This page uses content from Wikipedia. The original article was at Thiele's interpolation formula. 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)
Thiele's interpolation formula is an interpolation ... | #zkl | zkl | const N=32, N2=(N * (N - 1) / 2), STEP=0.05;
fcn rho(xs,ys,rs, i,n){
if (n < 0) return(0.0);
if (not n) return(ys[i]);
idx := (N - 1 - n) * (N - n) / 2 + i;
if (Void==rs[idx])
rs[idx] = (xs[i] - xs[i + n])
/ (rho(xs, ys, rs, i, n - 1) - rho(xs, ys, rs, i + 1, n - 1))
+ rho(xs, ys, rs, i + 1, n... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #COBOL | COBOL | IDENTIFICATION DIVISION.
PROGRAM-ID. text-processing-2.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT readings ASSIGN Input-File-Path
ORGANIZATION LINE SEQUENTIAL
FILE STATUS file-status.
DATA DIVISION.
FILE... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #Factor | Factor | USING: ascii combinators interpolate io kernel locals
pair-rocket qw sequences ;
IN: rosetta-code.name-game
: vowel? ( char -- ? ) "AEIOU" member? ;
:: name-game ( Name -- )
Name first :> L
Name >lower :> name! L vowel? [ name rest name! ] unless
"b" :> B!
"f" :> F!
"m" ... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #FreeBASIC | FreeBASIC | Sub TheGameName(nombre As String)
Dim As String x = Lcase(nombre)
x = Ucase(Mid(x,1,1)) + (Mid(x,2,Len(x)-1))
Dim As String x0 = Ucase(Mid(x,1,1))
Dim As String y
If x0 = "A" Or x0 = "E" Or x0 = "I" Or x0 = "O" Or x0 = "U" Then
y = Lcase(x)
Else
y = Mid(x,2)
End If
Di... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #Factor | Factor | USING: assocs assocs.extras interpolate io io.encodings.utf8
io.files kernel literals math math.parser prettyprint sequences
unicode ;
<< CONSTANT: src "unixdict.txt" >>
CONSTANT: words
$[ src utf8 file-lines [ [ letter? ] all? ] filter ]
CONSTANT: digits "22233344455566677778889999"
: >phone ( str -- n )
... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #Go | Go | package main
import (
"bufio"
"flag"
"fmt"
"io"
"log"
"os"
"strings"
"unicode"
)
func main() {
log.SetFlags(0)
log.SetPrefix("textonyms: ")
wordlist := flag.String("wordlist", "wordlist", "file containing the list of words to check")
flag.Parse()
if flag.NArg() != 0 {
flag.Usage()
os.Exit(2)
}
... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #AWK | AWK | $2=="OUT" {
count = count + 1
time = $4
if ( count > maxcount ) {
maxcount = count
maxtimes = time
} else {
if ( count == maxcount ) {
maxtimes = maxtimes " and " time
}
}
}
$2=="IN" { count = count - 1 }
END {print "The biggest number of licenses is... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #D | D | void main() {
import std.stdio, std.array, std.string, std.regex, std.conv,
std.algorithm;
auto rxDate = `^\d\d\d\d-\d\d-\d\d$`.regex;
// Works but eats lot of RAM in DMD 2.064.
// auto rxDate = ctRegex!(`^\d\d\d\d-\d\d-\d\d$`);
int[string] repeatedDates;
int goodReadings;
for... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #F.C5.8Drmul.C3.A6 | Fōrmulæ | package main
import (
"fmt"
"strings"
)
func printVerse(name string) {
x := strings.Title(strings.ToLower(name))
y := x[1:]
if strings.Contains("AEIOU", x[:1]) {
y = strings.ToLower(x)
}
b := "b" + y
f := "f" + y
m := "m" + y
switch x[0] {
case 'B':
b = y
... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #Haskell | Haskell | import Data.Char (toUpper)
import Data.Function (on)
import Data.List (groupBy, sortBy)
import Data.Maybe (fromMaybe, isJust, isNothing)
toKey :: Char -> Maybe Char
toKey ch
| ch < 'A' = Nothing
| ch < 'D' = Just '2'
| ch < 'G' = Just '3'
| ch < 'J' = Just '4'
| ch < 'M' = Just '5'
| ch < 'P' = Just '6'
... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #BBC_BASIC | BBC BASIC | max% = 0
nlicence% = 0
file% = OPENIN("mlijobs.txt")
WHILE NOT EOF#file%
a$ = GET$#file%
stamp$ = MID$(a$, 15, 19)
IF INSTR(a$, "OUT") THEN
nlicence% += 1
IF nlicence% > max% THEN
max% = nlicence%
start$ = stamp$
END... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #Bracmat | Bracmat | ( 0:?N:?n
& :?Ts
& @( get$("mlijobs.txt",STR)
: ?
( "e " ?OI " @ " ?T " " ?
& ( !OI:OUT
& !n+1
: ( >!N:?N&!T:?Ts
| !N&!Ts !T:?Ts
| ?
)
| !n+-1
)
: ?n
... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #Eiffel | Eiffel |
class
APPLICATION
create
make
feature
make
-- Finds double date stamps and wrong formats.
local
found: INTEGER
double: STRING
do
read_wordlist
fill_hash_table
across
hash as h
loop
if h.key.has_substring ("_double") then
io.put_string ("Double date stamp: %N")
doubl... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #Go | Go | package main
import (
"fmt"
"strings"
)
func printVerse(name string) {
x := strings.Title(strings.ToLower(name))
y := x[1:]
if strings.Contains("AEIOU", x[:1]) {
y = strings.ToLower(x)
}
b := "b" + y
f := "f" + y
m := "m" + y
switch x[0] {
case 'B':
b = y
... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #Io | Io | main := method(
setupLetterToDigitMapping
file := File clone openForReading("./unixdict.txt")
words := file readLines
file close
wordCount := 0
textonymCount := 0
dict := Map clone
words foreach(word,
(key := word asPhoneDigits) ifNonNil(
wordCount = wordCount+1
... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #C | C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#define INOUT_LEN 4
#define TIME_LEN 20
#define MAX_MAXOUT 1000
char inout[INOUT_LEN];
char time[TIME_LEN];
uint jobnum;
char maxtime[MAX_MAXOUT][TIME_LEN];
int main(int argc, char **argv)
{
FILE *in = NULL;
int l_out = 0, max... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #Erlang | Erlang |
-module( text_processing2 ).
-export( [task/0] ).
task() ->
Name = "priv/readings.txt",
try
File_contents = text_processing:file_contents( Name ),
[correct_field_format(X) || X<- File_contents],
{_Previous, Duplicates} = lists:foldl( fun date_duplicates/2, {"", []}, File_contents ),
io:fwrite( "Duplicates: ... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #Haskell | Haskell |
-- The Name Game, Ethan Riley, 22nd May 2018
import Data.Char
isVowel :: Char -> Bool
isVowel c
| char == 'A' = True
| char == 'E' = True
| char == 'I' = True
| char == 'O' = True
| char == 'U' = True
| otherwise = False
where char = toUpper c
isSpecial :: Char -> Bool
isSpecial c ... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #J | J | require'regex strings web/gethttp'
strip=:dyad define
(('(?s)',x);'') rxrplc y
)
fetch=:monad define
txt=. '.*<pre>' strip '</pre>.*' strip gethttp y
cutopen tolower txt-.' '
)
keys=:noun define
2 abc
3 def
4 ghi
5 jkl
6 mno
7 pqrs
8 tuv
9 wxyz
)
reporttext=:noun define
There are #{0} words in #{1... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #C.23 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace TextProc3
{
class Program
{
static void Main(string[] args)
{
string line;
int count = 0, maxcount = 0;
List<string> times = new Li... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #F.23 | F# |
let file = @"readings.txt"
let dates = HashSet(HashIdentity.Structural)
let mutable ok = 0
do
for line in System.IO.File.ReadAllLines file do
match String.split [' '; '\t'] line with
| [] -> ()
| date::xys ->
if dates.Contains date then
printf "Date %s is duplicated\n" date
... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #J | J |
T=:TEMPLATE=: noun define
(X), (X), bo-b(Y)
Banana-fana fo-f(Y)
Fee-fi-mo-m(Y)
(X)!
)
nameGame=: monad define
X=. y
Y=. tolower }.^:('aeiouAEIOU' -.@:e.~ {.) y
heady=. tolower {. y
t=. TEMPLATE -. '()'
'ix iy'=. I. 'XY' =/ t
tbox=. ;/ t
match=. heady = (<: iy){::"0 _ tbox
remove =. match # iy
s... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #Java | Java | import java.util.stream.Stream;
public class NameGame {
private static void printVerse(String name) {
StringBuilder sb = new StringBuilder(name.toLowerCase());
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
String x = sb.toString();
String y = "AEIOU".indexOf(x.charAt(0)) > ... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #Java | Java |
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;
public class RTextonyms {
private static... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #C.2B.2B | C++ | #include <fstream>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
int main()
{
const char logfilename[] = "mlijobs.txt";
std::ifstream logfile(logfilename);
if (!logfile.is_open())
{
std::cerr << "Error opening: " << logfilename << "\n";
return -1;
}
... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #Factor | Factor | USING: io io.encodings.ascii io.files kernel math math.parser
prettyprint sequences sequences.extras sets splitting ;
: check-format ( seq -- )
[ " \t" split length 49 = ] all?
"Format okay." "Format not okay." ? print ;
"readings.txt" ascii file-lines [ check-format ] keep
[ "Duplicates:" print [ "\t" spli... |
http://rosettacode.org/wiki/The_Name_Game | The Name Game | Write a program that accepts a name as input and outputs the lyrics to the Shirley Ellis song "The Name Game".
The regular verse
Unless your name begins with a vowel (A, E, I, O, U), 'B', 'F' or 'M' you don't have to care about special rules.
The verse for the name 'Gary' would be like this:
Gary, Gary, bo-bary... | #JavaScript | JavaScript | function singNameGame(name) {
// normalize name
name = name.toLowerCase();
name = name[0].toUpperCase() + name.slice(1);
// ... and sometimes y
// let's pray this works
let firstVowelPos = (function() {
let vowels =
'aeiouàáâãäåæèéêëìíîïòóôõöøùúûüāăąēĕėęěĩīĭįıijōŏőœũūŭůűų'
.split('');
f... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #jq | jq | def textonym_value:
gsub("a|b|c|A|B|C"; "2")
| gsub("d|e|f|D|E|F"; "3")
| gsub("g|h|i|G|H|I"; "4")
| gsub("j|k|l|J|K|L"; "5")
| gsub("m|n|o|M|N|O"; "6")
| gsub("p|q|r|s|P|Q|R|S"; "7")
| gsub("t|u|v|T|U|V"; "8")
| gsub("w|x|y|z|W|X|Y|Z"; "9");
def explore:
# given an array (or hash), find the maxim... |
http://rosettacode.org/wiki/Textonyms | Textonyms | When entering text on a phone's digital pad it is possible that a particular combination of digits corresponds to more than one word. Such are called textonyms.
Assuming the digit keys are mapped to letters as follows:
2 -> ABC
3 -> DEF
4 -> GHI
5 -> JKL
6 -> MNO
7 -> PQRS
8 -> TUV
9 -... | #Julia | Julia | using Printf
const tcode = (Regex=>Char)[r"A|B|C|Ä|Å|Á|Â|Ç" => '2',
r"D|E|F|È|Ê|É" => '3',
r"G|H|I|Í" => '4',
r"J|K|L" => '5',
r"M|N|O|Ó|Ö|Ô|Ñ" => '6',
r"P|Q|R|S" => '7',
... |
http://rosettacode.org/wiki/Text_processing/Max_licenses_in_use | Text processing/Max licenses in use | A company currently pays a fixed sum for the use of a particular licensed software package. In determining if it has a good deal it decides to calculate its maximum use of the software from its license management log file.
Assume the software's licensing daemon faithfully records a checkout event when a copy of the ... | #Clojure | Clojure | (defn delta [entry]
(case (second (re-find #"\ (.*)\ @" entry))
"IN " -1
"OUT" 1
(throw (Exception. (str "Invalid entry:" entry)))))
(defn t [entry]
(second (re-find #"@\ (.*)\ f" entry)))
(let [entries (clojure.string/split (slurp "mlijobs.txt") #"\n")
in-use (reductions + (map delta entries)... |
http://rosettacode.org/wiki/Text_processing/2 | Text processing/2 | The following task concerns data that came from a pollution monitoring station with twenty-four instruments monitoring twenty-four aspects of pollution in the air. Periodically a record is added to the file, each record being a line of 49 fields separated by white-space, which can be one or more space or tab characters... | #Fortran | Fortran |
Crunches a set of hourly data. Starts with a date, then 24 pairs of value,indicator for that day, on one line.
INTEGER Y,M,D !Year, month, and day.
INTEGER GOOD(24,2) !The indicators.
REAL*8 V(24,2) !The grist.
CHARACTER*10 DATE(2) !Along with the starting date.
INTEGER IT,TI !A fl... |
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.