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/Deepcopy | Deepcopy | Task
Demonstrate how to copy data structures containing complex heterogeneous and cyclic semantics.
This is often referred to as deep copying, and is normally required where structures are mutable and to ensure that independent copies can be manipulated without side-effects.
If this facility is not built into the la... | #Wren | Wren | import "/trait" for Cloneable, CloneableSeq
import "/seq" for Lst
class MyMap is Cloneable {
construct new (m) {
if (m.type != Map) Fiber.abort("Argument must be a Map.")
_m = m
}
m { _m }
toString { _m.toString }
clone() {
// Map keys are always immutable built-in ty... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #BBC_BASIC | BBC BASIC | *FLOAT 64
hand% = 617
REM Initialise card library:
SYS "LoadLibrary", "CARDS.DLL" TO cards%
IF cards% = 0 ERROR 100, "No CARDS library"
SYS "GetProcAddress", cards%, "cdtInit" TO cdtInit%
SYS "GetProcAddress", cards%, "cdtDraw" TO cdtDraw%
SYS cdtInit%, ^dx%, ^dy%
... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Befunge | Befunge | vutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDC
>4$0" :rebmun emaG">:#,_$&>55+,>"O?+"**2+*"C4'' "**v
>8%!492*+*48*\-,1-:11p0g\0p11g#^_@A23456789TJQKCDHS*
^+3:g11,g2+"/"%4,g2+g14/4:-\"v"g0:%g11+*-/2-10-1*<>+
>8#8*#4*#::#%*#*/#*:#*0#:\#*`#:8#::#*:#8*#8:#2*#+^#< |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #C.23 | C# | using System;
using System.Collections.Generic;
using System.Text;
namespace DeBruijn {
class Program {
const string digits = "0123456789";
static string DeBruijn(int k, int n) {
var alphabet = digits.Substring(0, k);
var a = new byte[k * n];
var seq = new Lis... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Factor | Factor | PREDICATE: my-int < integer [ 0 > ] [ 11 < ] bi and ; |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Forth | Forth | DECIMAL
: CLIP ( n lo hi -- n') ROT MIN MAX ;
: BETWEEN ( n lo hi -- flag) 1+ WITHIN ;
\ programmer chooses CLIPPED or SAFE integer assignment
: CLIP! ( n addr -- ) SWAP 1 10 CLIP SWAP ! ;
: SAFE! ( n addr -- )
OVER 1 10 BETWEEN 0= ABORT" out of range!"
! ; |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Delphi | Delphi |
program Death_Star;
{$APPTYPE CONSOLE}
uses
Winapi.Windows,
System.SysUtils,
system.Math,
Vcl.Graphics,
Vcl.Imaging.pngimage;
type
TVector = array of double;
var
light: TVector = [20, -40, -10];
function ClampInt(value, amin, amax: Integer): Integer;
begin
Result := Max(amin, Min(amax, value... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #PicoLisp | PicoLisp | (load "@lib/math.l")
(de deconv (G F)
(let A (pop 'F)
(make
(for (N . H) (head (- (length F)) G)
(for (I . M) (made)
(dec 'H
(*/ M (get F (- N I)) 1.0) ) )
(link (*/ H 1.0 A)) ) ) ) ) |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Python | Python | def ToReducedRowEchelonForm( M ):
if not M: return
lead = 0
rowCount = len(M)
columnCount = len(M[0])
for r in range(rowCount):
if lead >= columnCount:
return
i = r
while M[i][lead] == 0:
i += 1
if i == rowCount:
i = r
... |
http://rosettacode.org/wiki/Deepcopy | Deepcopy | Task
Demonstrate how to copy data structures containing complex heterogeneous and cyclic semantics.
This is often referred to as deep copying, and is normally required where structures are mutable and to ensure that independent copies can be manipulated without side-effects.
If this facility is not built into the la... | #Z80_Assembly | Z80 Assembly | LD HL,(&C000)
LD (&D000),HL |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Bracmat | Bracmat | ( ( createArray
= array rank ranks suit suits
. A 2 3 4 5 6 7 8 9 T J Q K:?ranks
& :?array
& whl
' ( !ranks:%?rank ?ranks
& ♣ ♦ ♥ ♠:?suits
& whl
' ( !suits:%?suit ?suits
& !array str$(!rank !suit):?array
)
)
&... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #C | C | #include <stdio.h>
#include <stdlib.h>
#include <locale.h>
wchar_t s_suits[] = L"♣♦♥♠", s_nums[] = L"A23456789TJQK";
#define RMAX32 ((1U << 31) - 1)
static int seed = 1;
int rnd(void) { return (seed = (seed * 214013 + 2531011) & RMAX32) >> 16; }
void srnd(int x) { seed = x; }
void show(const int *c)
{
int i;
f... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #C.2B.2B | C++ | #include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
#include <string>
#include <sstream>
#include <vector>
typedef unsigned char byte;
std::string deBruijn(int k, int n) {
std::vector<byte> a(k * n, 0);
std::vector<byte> seq;
std::function<void(int, int)> db;
db = [&... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Fortran | Fortran | module Bounded
implicit none
type BoundedInteger
integer, private :: v ! we cannot allow direct access to this, or we
integer, private :: from, to ! can't check the bounds!
logical, private :: critical
end type BoundedInteger
interface assignment(=)
module procedure bounded_as... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #DWScript | DWScript | const cShades = '.:!*oe&#%@';
type TVector = array [0..2] of Float;
var light : TVector = [-50.0, 30, 50];
procedure Normalize(var v : TVector);
begin
var len := Sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
v[0] /= len; v[1] /= len; v[2] /= len;
end;
function Dot(x, y : TVector) : Float;
begin
var d :=x[0]... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #R | R | conv <- function(a, b) {
p <- length(a)
q <- length(b)
n <- p + q - 1
r <- nextn(n, f=2)
y <- fft(fft(c(a, rep(0, r-p))) * fft(c(b, rep(0, r-q))), inverse=TRUE)/r
y[1:n]
}
deconv <- function(a, b) {
p <- length(a)
q <- length(b)
n <- p - q + 1
r <- nextn(max(p, q), f=2)
y <- fft(fft(c(a, rep(0, r-p))) / ff... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Racket | Racket |
#lang racket
(require math/matrix)
(define T matrix-transpose)
(define (convolution-matrix f m n)
(define l (matrix-num-rows f))
(for*/matrix m n ([i (in-range 0 m)] [j (in-range 0 n)])
(cond [(or (< i j) (>= i (+ j l))) 0]
[(matrix-ref f (- i j) 0)])))
(define (least-square X y)
(matrix... |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #C | C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
double PI;
typedef double complex cplx;
void _fft(cplx buf[], cplx out[], int n, int step)
{
if (step < n) {
_fft(out, buf, n, step * 2);
_fft(out + step, buf + step, n, step * 2);
for (int i = 0; i < n; i += 2 * step) {
cplx ... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #C.23 | C# | using System;
using System.Collections.Generic;
using System.Text;
namespace FreeCellDeals
{
public class RNG
{
private int _state;
public RNG()
{
_state = (int)DateTime.Now.Ticks;
}
public RNG(int n)
{
_state = n;
}
p... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #CLU | CLU | % Generate the De Bruijn sequence consisiting of N-digit numbers
de_bruijn = cluster is generate
rep = null
own k: int := 0
own n: int := 0
own a: array[int] := array[int]$[]
own seq: array[int] := array[int]$[]
generate = proc (k_, n_: int) returns (string)
k := k_
n := n_
... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #D | D | import std.array;
import std.conv;
import std.format;
import std.range;
import std.stdio;
immutable DIGITS = "0123456789";
string deBruijn(int k, int n) {
auto alphabet = DIGITS[0..k];
byte[] a;
a.length = k * n;
byte[] seq;
void db(int t, int p) {
if (t > n) {
if (n % p ==... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Free_Pascal | Free Pascal | type
range = 1..10;
var
n: range;
begin
n := 10;
{$rangeChecks on}
n := n + 10; // will yield a run-time error
end; |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Frink | Frink | res = 254 / in
v = callJava["frink.graphics.VoxelArray", "makeSphere", [1/2 inch res]]
dish = callJava["frink.graphics.VoxelArray", "makeSphere", [1/2 inch res]]
dish.translate[round[.45 inch res], round[.45 inch res], round[.45 inch res]]
v.remove[dish]
v.projectX[undef].show["X"]
v.projectY[undef].show["Y"]
v.pro... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Go | Go | package main
import (
"fmt"
"image"
"image/color"
"image/png"
"math"
"os"
)
type vector [3]float64
func (v *vector) normalize() {
invLen := 1 / math.Sqrt(dot(v, v))
v[0] *= invLen
v[1] *= invLen
v[2] *= invLen
}
func dot(x, y *vector) float64 {
return x[0]*y[0] + x[1]... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Raku | Raku | sub deconvolve (@g, @f) {
my \h = 1 + @g - @f;
my @m;
@m[^@g;^h] »+=» 0;
@m[^@g; h] »=« @g;
for ^h -> \j { for @f.kv -> \k, \v { @m[j+k;j] = v } }
(rref @m)[^h;h]
}
sub convolve (@f, @h) {
my @g = 0 xx + @f + @h - 1;
@g[^@f X+ ^@h] »+=« (@f X× @h);
@g
}
# Reduced Row Echelon For... |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #D | D | import std.stdio, std.conv, std.algorithm, std.numeric, std.range;
class M(T) {
private size_t[] dim;
private size_t[] subsize;
private T[] d;
this(size_t[] dimension...) pure nothrow {
setDimension(dimension);
d[] = 0; // init each entry to zero;
}
M!T dup() {
aut... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #C.2B.2B | C++ |
#include <windows.h>
#include <iostream>
//--------------------------------------------------------------------------------------------------
using namespace std;
//--------------------------------------------------------------------------------------------------
class fc_dealer
{
public:
void deal( int game ... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Go | Go | package main
import (
"bytes"
"fmt"
"strconv"
"strings"
)
const digits = "0123456789"
func deBruijn(k, n int) string {
alphabet := digits[0:k]
a := make([]byte, k*n)
var seq []byte
var db func(int, int) // recursive closure
db = func(t, p int) {
if t > n {
i... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #FreeBASIC | FreeBASIC | ' FB 1.05.0 Win64
Type MyInteger
Private:
Dim i_ As Integer
Public:
Declare Constructor(i_ As Integer)
Declare Property I() As Integer
Declare Operator Cast() As Integer
Declare Operator Cast() As String
End Type
Constructor MyInteger(i_ As Integer)
If i_ < 1 Then
i_ = 1
E... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Haskell | Haskell | import Data.List (genericLength)
shades = ".:!*oe%#&@"
n = genericLength shades
dot a b = sum $ zipWith (*) a b
normalize x = (/ sqrt (x `dot` x)) <$> x
deathStar r k amb = unlines $
[ [ if x*x + y*y <= r*r
then let vec = normalize $ normal x y
b = (light `dot` vec) ** k + amb
... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #REXX | REXX | /*REXX pgm performs deconvolution of two arrays: deconv(g,f)=h and deconv(g,h)=f */
call make 'H', "-8 -9 -3 -1 -6 7"
call make 'F', "-3 -6 -1 8 -6 3 -1 -9 -9 3 -2 5 2 -2 -7 -1"
call make 'G', "24 75 71 -34 3 22 -45 23 245 25 52 25 -67 -96 96 31 55 36 29 -43 -7"
call show 'H' ... |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #Go | Go | package main
import (
"fmt"
"math"
"math/cmplx"
)
func fft(buf []complex128, n int) {
out := make([]complex128, n)
copy(out, buf)
fft2(buf, out, n, 1)
}
func fft2(buf, out []complex128, n, step int) {
if step < n {
fft2(out, buf, n, step*2)
fft2(out[step:], buf[step:], ... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Ceylon | Ceylon | shared void freeCellDeal() {
//a function that returns a random number generating function
function createRNG(variable Integer state) =>
() => (state = (214_013 * state + 2_531_011) % 2^31) / 2^16;
void deal(Integer num) {
// create an array with a list comprehension
variable value deck = Array {
for(... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Clojure | Clojure | (def deck (into [] (for [rank "A23456789TJQK" suit "CDHS"] (str rank suit))))
(defn lcg [seed]
(map #(bit-shift-right % 16)
(rest (iterate #(mod (+ (* % 214013) 2531011) (bit-shift-left 1 31)) seed))))
(defn gen [seed]
(map (fn [rnd rng] (into [] [(mod rnd rng) (dec rng)]))
(lcg seed) (range 52 0 -1))... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Groovy | Groovy | import java.util.function.BiConsumer
class DeBruijn {
interface Recursable<T, U> {
void apply(T t, U u, Recursable<T, U> r);
}
static <T, U> BiConsumer<T, U> recurse(Recursable<T, U> f) {
return { t, u -> f.apply(t, u, f) }
}
private static String deBruijn(int k, int n) {
... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Frink | Frink | oneToTen[x] := isInteger[x] AND x >= 1 AND x <= 10
var y is oneToTen = 1
while (true)
{
println[y]
y = y + 1
} |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Go | Go | package main
import "fmt"
type TinyInt int
func NewTinyInt(i int) TinyInt {
if i < 1 {
i = 1
} else if i > 10 {
i = 10
}
return TinyInt(i)
}
func (t1 TinyInt) Add(t2 TinyInt) TinyInt {
return NewTinyInt(int(t1) + int(t2))
}
func (t1 TinyInt) Sub(t2 TinyInt) TinyInt {
re... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #J | J |
load'graphics/viewmat'
mag =: +/&.:*:"1
norm=: %"1 0 mag
dot =: +/@:*"1
NB. (pos;posr;neg;negr) getvec (x,y)
getvec =: 4 :0 "1
pt =. y
'pos posr neg negr' =. x
if. (dot~ pt-}:pos) > *:posr do.
0 0 0
else.
zb =. ({:pos) (-,+) posr -&.:*: pt mag@:- }:pos
if. (dot~ pt-}:neg) > *:negr do.
(pt... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Scala | Scala | object Deconvolution1D extends App {
val (h, f) = (Array(-8, -9, -3, -1, -6, 7), Array(-3, -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1))
val g = Array(24, 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96, 96, 31, 55, 36, 29, -43, -7)
val sb = new StringBuilder
private def deconv(g: Array[Int],... |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #J | J | deconv3 =: 4 : 0
sz =. x >:@-&$ y NB. shape of z
poi =. ,<"1 ($y) ,"0/&(,@i.) sz NB. pair of indexes
t=. /: sc=: , <@(+"1)/&(#: ,@i.)/ ($y),:sz NB. order of ,y
T0=. (<"0,x) ,:~ (]/:"1 {.)&.> (<, y) ({:@] ,: ({"1~ {.))&.> sc <@|:@:>/.&(t&{) po... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Common_Lisp | Common Lisp | (defun make-rng (seed)
#'(lambda ()
(ash (setf seed (mod (+ (* 214013 seed) 2531011) (expt 2 31))) -16)))
(defun split (s) (map 'list #'string s))
(defun make-deck (seed)
(let ((hand (make-array 52 :fill-pointer 0))
(rng (make-rng seed)))
(dolist (d (split "A23456789TJQK"))
(dolist (s (split "♣♦♥♠... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Haskell | Haskell | import Data.List
import Data.Map ((!))
import qualified Data.Map as M
-- represents a permutation in a cycle notation
cycleForm :: [Int] -> [[Int]]
cycleForm p = unfoldr getCycle $ M.fromList $ zip [0..] p
where
getCycle p
| M.null p = Nothing
| otherwise =
let Just ((x,y), m) = M.minView... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Haskell | Haskell | {-# OPTIONS -fglasgow-exts #-}
data Check a b = Check { unCheck :: b } deriving (Eq, Ord)
class Checked a b where
check :: b -> Check a b
lift f x = f (unCheck x)
liftc f x = check $ f (unCheck x)
lift2 f x y = f (unCheck x) (unCheck y)
lift2c f x y = check $ f (unCheck x) (unCheck y)
lift2p f x y = (check ... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Java | Java | import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Point3D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.shape.MeshView;
import javafx.scene.shape.TriangleMesh;
import javafx.... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Swift | Swift | func deconv(g: [Double], f: [Double]) -> [Double] {
let fs = f.count
var ret = [Double](repeating: 0, count: g.count - fs + 1)
for n in 0..<ret.count {
ret[n] = g[n]
let lower = n >= fs ? n - fs + 1 : 0
for i in lower..<n {
ret[n] -= ret[i] * f[n - i]
}
ret[n] /= f[0]
}
retur... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Tcl | Tcl | package require Tcl 8.5
namespace eval 1D {
namespace ensemble create; # Will be same name as namespace
namespace export convolve deconvolve
# Access core language math utility commands
namespace path {::tcl::mathfunc ::tcl::mathop}
# Utility for converting a matrix to Reduced Row Echelon Form
... |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #Julia | Julia | using FFTW, DSP
const h1 = [-8, 2, -9, -2, 9, -8, -2]
const f1 = [ 6, -9, -7, -5]
const g1 = [-48, 84, -16, 95, 125, -70, 7, 29, 54, 10]
const h2nested = [
[-8, 1, -7, -2, -9, 4],
[4, 5, -5, 2, 7, -1],
[-6, -3, -3, -6, 9, 5]]
const f2nested = [
[-5, 2, -2, -6, -7],
[9, 7, -6, 5, -7],
... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #D | D | import std.stdio, std.conv, std.algorithm, std.range;
struct RandomGenerator {
uint seed = 1;
@property uint next() pure nothrow @safe @nogc {
seed = (seed * 214_013 + 2_531_011) & int.max;
return seed >> 16;
}
}
struct Deck {
int[52] cards;
void deal(in uint seed) pure nothr... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #J | J | NB. implement inverse Burrows—Wheeler transform sequence method
repeat_alphabet=: [: , [: i.&> (^ <:) # [
assert 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 -: 2 repeat_alphabet 4
de_bruijn=: ({~ ([: ; [: C. /:^:2))@:repeat_alphabet NB. K de_bruijn N
pins=: #&10 #: [: i. 10&^ NB. pins y generates all y digit PINs
gro... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Java | Java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
public class DeBruijn {
public interface Recursable<T, U> {
void apply(T t, U u, Recursable<T, U> r);
}
public static <T, U> BiConsumer<T, U> recurse(Recursable<T, U> f) {
re... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #J | J |
NB. z locale by default on path.
type_z_=: 3!:0
nameClass_z_=: 4!:0
signalError_z_=: 13!:8
NB. create a restricted object from an appropriate integer
create_restrict_ =: monad define
'Domain error: expected integer' assert 1 4 e.~ type y NB. or Boolean
'Domain error: not on [1,10]' assert (0 -.@:e. [: , (0&<*.<&... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #JavaScript | JavaScript |
<!DOCTYPE html>
<html>
<body style="margin:0">
<canvas id="myCanvas" width="250" height="250" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
//Fill the canvas wit... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Ursala | Ursala | #import std
#import nat
band = pad0+ ~&rSS+ zipt^*D(~&r,^lrrSPT/~<K33tx zipt^/~&r ~&lSNyCK33+ zipp0)^/~&rx ~&B->NlNSPC ~&bt
deconv = lapack..dgelsd^\~&l ~&||0.!**+ band
|
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Vlang | Vlang | fn main() {
h := [f64(-8), -9, -3, -1, -6, 7]
f := [f64(-3), -6, -1, 8, -6, 3, -1, -9, -9, 3, -2, 5, 2, -2, -7, -1]
g := [f64(24), 75, 71, -34, 3, 22, -45, 23, 245, 25, 52, 25, -67, -96,
96, 31, 55, 36, 29, -43, -7]
println(h)
println(deconv(g, f))
println(f)
println(deconv(g, h))
}
... |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | Round[ListDeconvolve[{6, -9, -7, -5}, {-48, 84, -16, 95, 125, -70, 7, 29, 54, 10}, Method -> "Wiener"]]
Round[ListDeconvolve[{{-5, 2, -2, -6, -7}, {9, 7, -6, 5, -7}, {1, -1, 9, 2, -7}, {5, 9, -9, 2, -5}, {-8, 5, -2, 8, 5}},
{{40, -21, 53, 42, 105, 1, 87, 60, 39, -28}, {-92, -64, 19, -167, -71, -47, 128, -109, 40, -2... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Delphi | Delphi |
program Deal_cards_for_FreeCell;
{$APPTYPE CONSOLE}
uses
System.SysUtils;
type
TRandom = record
Seed: Int64;
function Next: Integer;
end;
TCard = record
const
kSuits = '♣♦♥♠';
kValues = 'A23456789TJQK';
var
Value: Integer;
Suit: Integer;
procedure Create(raw... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Julia | Julia | function debruijn(k::Integer, n::Integer)
alphabet = b"0123456789abcdefghijklmnopqrstuvwxyz"[1:k]
a = zeros(UInt8, k * n)
seq = UInt8[]
function db(t, p)
if t > n
if n % p == 0
append!(seq, a[2:p+1])
end
else
a[t + 1] = a[t - p + 1]
... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Kotlin | Kotlin | const val digits = "0123456789"
fun deBruijn(k: Int, n: Int): String {
val alphabet = digits.substring(0, k)
val a = ByteArray(k * n)
val seq = mutableListOf<Byte>()
fun db(t: Int, p: Int) {
if (t > n) {
if (n % p == 0) {
seq.addAll(a.sliceArray(1..p).asList())
... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Java | Java | class BoundedIntOutOfBoundsException extends Exception
{
public BoundedIntOutOfBoundsException(int v, int l, int u) {
super("value " + v + " is out of bounds [" + l + "," + u + "]");
}
}
class BoundedInt {
private int value;
private int lower;
private int upper;
public BoundedInt(int l, int u) {
... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Julia | Julia | # run in REPL
using GLMakie
function deathstar()
n = 60
θ = [0; (0.5: n - 0.5) / n; 1]
φ = [(0: 2n - 2) * 2 / (2n - 1); 2]
# if x is +0.9 radius units, replace it with the coordinates of sphere surface
# at (1.2,0,0) center, radius 0.5 units
x = [(x1 = cospi(φ)*sinpi(θ)) > 0.9 ? 1.2 - x1 * 0.5... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #LSL | LSL | default {
state_entry() {
llSetPrimitiveParams([PRIM_NAME, "RosettaCode DeathStar"]);
llSetPrimitiveParams([PRIM_DESC, llGetObjectName()]);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SPHERE, PRIM_HOLE_CIRCLE, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <0.12, 1.0, 0.0>]);
llSetPrimitivePa... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #Wren | Wren | var deconv = Fn.new { |g, f|
var h = List.filled(g.count - f.count + 1, 0)
for (n in 0...h.count) {
h[n] = g[n]
var lower = (n >= f.count) ? n - f.count + 1 : 0
var i = lower
while (i < n) {
h[n] = h[n] - h[i]*f[n-i]
i = i + 1
}
h[n] = h[n]... |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #Nim | Nim | import sequtils, typetraits
type Size = uint64
type M[T: SomeNumber] = object
dims: seq[Size]
subsizes: seq[Size]
data: seq[T]
####################################################################################################
# Miscellaneous.
func dotProduct[T: SomeNumber](a, b: openArray[T]): T =
ass... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Elixir | Elixir | defmodule FreeCell do
import Bitwise
@suits ~w( C D H S )
@pips ~w( A 2 3 4 5 6 7 8 9 T J Q K )
@orig_deck for pip <- @pips, suit <- @suits, do: pip <> suit
def deal(games) do
games = if length(games) == 0, do: [Enum.random(1..32000)], else: games
Enum.each(games, fn seed ->
IO.puts "Game ##... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #ERRE | ERRE |
PROGRAM FREECELL
!$DOUBLE
DIM CARDS%[52]
PROCEDURE XRANDOM(SEED->XRND)
POW31=2^31
POW16=2^16
SEED=SEED*214013+2531011
SEED=SEED-POW31*INT(SEED/POW31)
XRND=INT(SEED/POW16)
END PROCEDURE
PROCEDURE DEAL(CARDS%[],GAME_NUM)
LOCAL I%,J%,S%
SEED=GAME_NUM
FOR I%=1 TO 52 DO
CARDS%... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Lua | Lua | function tprint(tbl)
for i,v in pairs(tbl) do
print(v)
end
end
function deBruijn(k, n)
local a = {}
for i=1, k*n do
table.insert(a, 0)
end
local seq = {}
function db(t, p)
if t > n then
if n % p == 0 then
for i=1, p do
... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #JavaScript | JavaScript | function Num(n){
n = Math.floor(n);
if(isNaN(n))
throw new TypeError("Not a Number");
if(n < 1 || n > 10)
throw new TypeError("Out of range");
this._value = n;
}
Num.prototype.valueOf = function() { return this._value; }
Num.prototype.toString = function () { return this._value.toString(... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Lua | Lua | function V3(x,y,z) return {x=x,y=y,z=z} end
function dot(v,w) return v.x*w.x + v.y*w.y + v.z*w.z end
function norm(v) local m=math.sqrt(dot(v,v)) return V3(v.x/m, v.y/m, v.z/m) end
function clamp(n,lo,hi) return math.floor(math.min(math.max(lo,n),hi)) end
function hittest(s, x, y)
local z = s.r^2 - (x-s.x)^2 - (y-s.y... |
http://rosettacode.org/wiki/Deconvolution/1D | Deconvolution/1D | The convolution of two functions
F
{\displaystyle {\mathit {F}}}
and
H
{\displaystyle {\mathit {H}}}
of
an integer variable is defined as the function
G
{\displaystyle {\mathit {G}}}
satisfying
G
(
n
)
=
∑
m
=
−
∞
∞
F
(
m
)
H
(
n
−
m
)
{\displaystyle G(n)=\sum _{m=-\inft... | #zkl | zkl | var [const] GSL=Import("zklGSL"); // libGSL (GNU Scientific Library)
fcn dconv1D(f,g){
fsz,hsz:=f.len(), g.len() - fsz +1;
A:=GSL.Matrix(g.len(),hsz);
foreach n,fn in ([0..].zip(f)){ foreach rc in (hsz){ A[rc+n,rc]=fn } }
h:=A.AxEQb(g);
h
} |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #Perl | Perl | use feature 'say';
use ntheory qw/forsetproduct/;
# Deconvolution of N dimensional matrices
sub deconvolve_N {
our @g; local *g = shift;
our @f; local *f = shift;
my @df = shape(@f);
my @dg = shape(@g);
my @hsize;
push @hsize, $dg[$_] - $df[$_] + 1 for 0..$#df;
my @toSolve = map { [row(\@g... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #F.23 | F# |
let msKindaRand seed =
let state = ref seed
(fun (_:unit) ->
state := (214013 * !state + 2531011) &&& System.Int32.MaxValue
!state / (1<<<16))
let unshuffledDeck = [0..51] |> List.map(fun n->sprintf "%c%c" "A23456789TJQK".[n / 4] "CDHS".[n % 4])
let deal boot idx =
let (last,rest) = boot |> List... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Mathematica.2FWolfram_Language | Mathematica/Wolfram Language | seq = DeBruijnSequence[Range[0, 9], 4];
seq = seq~Join~Take[seq, 3];
Length[seq]
{seq[[;; 130]], seq[[-130 ;;]]}
Complement[
StringDrop[ToString[NumberForm[#, 4, NumberPadding -> {"0", "0"}]],
1] & /@ Range[0, 9999],
Union[StringJoin /@ Partition[ToString /@ seq, 4, 1]]]
seq = Reverse[seq];
Complement[
StringD... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Nim | Nim | import algorithm, parseutils, strformat, strutils
const Digits = "0123456789"
#---------------------------------------------------------------------------------------------------
func deBruijn(k, n: int): string =
let alphabet = Digits[0..<k]
var a = newSeq[byte](k * n)
var sequence: seq[byte]
#........... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #jq | jq | def typeof:
if type == "object" and has("type") then .type else type end; |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Julia | Julia | struct LittleInt <: Integer
val::Int8
function LittleInt(n::Real)
1 ≤ n ≤ 10 || throw(ArgumentError("LittleInt number must be in [1, 10]"))
return new(Int8(n))
end
end
Base.show(io::IO, x::LittleInt) = print(io, x.val)
Base.convert(::Type{T}, x::LittleInt) where T<:Number = convert(T, x.val)... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Maple | Maple | with(plots):
with(plottools):
plots:-display(
implicitplot3d(x^2 + y^2 + z^2 = 1, x = -1..0.85, y = -1..1, z = -1..1, style = surface, grid = [50,50,50]),
translate(rotate(implicitplot3d(x^2 + y^2 + z^2 = 1, x = 0.85..1, y = -1..1, z = -1..1, style = surface, grid = [50,50,50]), 0, Pi, 0), 1.70, 0, 0),
axes = non... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Mathematica_.2F_Wolfram_Language | Mathematica / Wolfram Language | RegionPlot3D[x^2 + y^2 + z^2 < 1 && (x + 1.7)^2 + y^2 + z^2 > 1,
{x, -1, 1}, {y, -1, 1}, {z, -1, 1},
Boxed -> False, Mesh -> False, Axes -> False, Background -> Black, PlotPoints -> 100] |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #Phix | Phix | -- demo\rosetta\Deconvolution.exw
with javascript_semantics
function m_size(sequence m)
--
-- returns the size of a matrix as a list of lengths
--
sequence res = {}
object me = m
while sequence(me) do
res &= length(me)
me = me[1]
end while
return res
end function
function make_coor... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Factor | Factor | USING: formatting grouping io kernel literals make math
math.functions namespaces qw sequences sequences.extras ;
IN: rosetta-code.freecell
CONSTANT: max-rand-ms $[ 1 15 shift 1 - ]
CONSTANT: suits qw{ C D H S }
CONSTANT: ranks qw{ A 2 3 4 5 6 7 8 9 T J Q K }
SYMBOL: seed
: (random) ( n1 n2 -- n3 ) seed get * + dup... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Pascal | Pascal |
program deBruijnSequence;
uses SysUtils;
// Create a de Bruijn sequence for the given word length and alphabet.
function deBruijn( const n : integer; // word length
const alphabet : string) : string;
var
d, k, m, s, t, seqLen : integer;
w : array of integer;
begin
k := Length( alphabet);
... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Kotlin | Kotlin | // version 1.1
class TinyInt(i: Int) {
private val value = makeTiny(i)
operator fun plus (other: TinyInt): TinyInt = TinyInt(this.value + other.value)
operator fun minus(other: TinyInt): TinyInt = TinyInt(this.value - other.value)
operator fun times(other: TinyInt): TinyInt = TinyInt(this.value * ot... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Nim | Nim | import math
import bitmap, grayscale_image, nimPNG
type
Vector = array[3, float]
Sphere = object
cx, cy, cz: int
r: int
#---------------------------------------------------------------------------------------------------
func dot(x, y: Vector): float {.inline.} =
x[0] * y[0] + x[1] * y[1] + x[... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Openscad | Openscad | // We are performing geometric subtraction
difference() {
// Create the primary sphere of radius 60 centred at the origin
translate(v = [0,0,0]) {
sphere(60);
}
/*Subtract an overlapping sphere with a radius of 40
The resultant hole will be smaller than this, because we only
only catch the... |
http://rosettacode.org/wiki/Day_of_the_week | Day of the week | A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
Task
In what years between 2008 and 2121 will the 25th of ... | #11l | 11l | print((2008..2121).filter(y -> Time(y, 12, 25).strftime(‘%w’) == ‘0’)) |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #Python | Python |
"""
https://rosettacode.org/wiki/Deconvolution/2D%2B
Working on 3 dimensional example using test data from the
RC task.
Python fft:
https://docs.scipy.org/doc/numpy/reference/routines.fft.html
"""
import numpy
import pprint
h = [
[[-6, -8, -5, 9], [-7, 9, -6, -8], [2, -7, 9, 8]],
[[7, 4, 4... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #Fortran | Fortran | module Freecell
use lcgs
implicit none
character(4) :: suit = "CDHS"
character(13) :: rank = "A23456789TJQK"
character(2) :: deck(0:51)
contains
subroutine Createdeck()
integer :: i, j, n
n = 0
do i = 1, 13
do j = 1, 4
deck(n) = rank(i:i) // suit(j:j)
n = n + 1
end do
end ... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Perl | Perl | use strict;
use warnings;
use feature 'say';
my $seq;
for my $x (0..99) {
my $a = sprintf '%02d', $x;
next if substr($a,1,1) < substr($a,0,1);
$seq .= (substr($a,0,1) == substr($a,1,1)) ? substr($a,0,1) : $a;
for ($a+1 .. 99) {
next if substr(sprintf('%02d', $_), 1,1) <= substr($a,0,1);
... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Lasso | Lasso | define dint => type {
data private value
public oncreate(value::integer) => {
fail_if(#value < 1,#value+' less than 1 ')
fail_if(#value > 10,#value+' greater than 10')
.value = #value
}
public +(rhs::integer) => dint(.value + #rhs)
public -(rhs::integer) => dint(.value - #rhs)
public *(rhs::int... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #Lua | Lua | BI = { -- Bounded Integer
new = function(self, v) return setmetatable({v = self:_limit(v)}, BI_mt) end,
_limit = function(self,v) return math.max(1, math.min(math.floor(v), 10)) end,
}
BI_mt = {
__index = BI,
__call = function(self,v) return self:new(v) end,
__unm = function(self) return BI(-self.v) end,
__... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Perl | Perl | use strict;
sub sq {
my $s = 0;
$s += $_ ** 2 for @_;
$s;
}
sub hit {
my ($sph, $x, $y) = @_;
$x -= $sph->[0];
$y -= $sph->[1];
my $z = sq($sph->[3]) - sq($x, $y);
return if $z < 0;
$z = sqrt $z;
return $sph->[2] - $z, $sph->[2] + $z;
}
sub normalize {
my $v = shift;
my $n = sqrt sq(@$v);
$_ /= $... |
http://rosettacode.org/wiki/Day_of_the_week | Day of the week | A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
Task
In what years between 2008 and 2121 will the 25th of ... | #360_Assembly | 360 Assembly | * Day of the week 06/07/2016
DOW CSECT
USING DOW,R15 base register
LA R6,2008 year=2008
LOOP C R6,=F'2121' do year=2008 to 2121
BH ELOOP .
LR R7,R6 y=year
LA R8,12 ... |
http://rosettacode.org/wiki/Day_of_the_week | Day of the week | A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
Task
In what years between 2008 and 2121 will the 25th of ... | #ABAP | ABAP | report zday_of_week
data: lv_start type i value 2007,
lv_n type i value 114,
lv_date type sy-datum,
lv_weekday type string,
lv_day type c,
lv_year type n length 4.
write 'December 25 is a Sunday in: '.
do lv_n times.
lv_year = lv_start + sy-index.
concatenate lv_year '12' '25' into... |
http://rosettacode.org/wiki/Deconvolution/2D%2B | Deconvolution/2D+ | This task is a straightforward generalization of Deconvolution/1D to higher dimensions. For example, the one dimensional case would be applicable to audio signals, whereas two dimensions would pertain to images. Define the discrete convolution in
d
{\displaystyle {\mathit {d}}}
dimensions of two functions
... | #Raku | Raku | # Deconvolution of N dimensional matrices.
sub deconvolve-N ( @g, @f ) {
my @hsize = @g.shape »-« @f.shape »+» 1;
my @toSolve = coords(@g.shape).map:
{ [row(@g, @f, $^coords, @hsize)] };
my @solved = rref( @toSolve );
my @h;
for flat coords(@hsize) Z @solved[*;*-1] -> $_, $v {
@h... |
http://rosettacode.org/wiki/Deal_cards_for_FreeCell | Deal cards for FreeCell | Free Cell is the solitaire card game that Paul Alfille introduced to the PLATO system in 1978. Jim Horne, at Microsoft, changed the name to FreeCell and reimplemented the game for DOS, then Windows.
This version introduced 32000 numbered deals. (The FreeCell FAQ tells this history.)
As the game became popular, Jim H... | #FreeBASIC | FreeBASIC | ' version 04-11-2016
' compile with: fbc -s console
' to seed ms_lcg(seed > -1)
' to get random number ms_lcg(-1) or ms_lcg() or just ms_lcg
Function ms_lcg(seed As Integer = -1) As UInteger
Static As UInteger ms_state
If seed <> -1 Then
ms_state = seed Mod 2 ^ 31
Else
ms_state = (2140... |
http://rosettacode.org/wiki/De_Bruijn_sequences | de Bruijn sequences | The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn.
A note on Dutch capitalization: Nicolaas' last name is de Bruijn, the de isn't normally capitalized
unless it's the first word in a sentence. Rosetta Code (more or less by default or by fiat) requires the first word in the... | #Phix | Phix | string deBruijn = ""
for n=0 to 99 do
string a = sprintf("%02d",n)
integer a1 = a[1],
a2 = a[2]
if a2>=a1 then
deBruijn &= iff(a1=a2?a1:a)
for m=n+1 to 99 do
string ms = sprintf("%02d",m)
if ms[2]>a1 then
deBruijn &= a&ms
end if... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #M2000_Interpreter | M2000 Interpreter |
Module CheckDataType {
Module CheckThis {
Class typeA {
Private:
mval as currency
Public:
Property min {value}=-1
Property max {value}=0
Operator "++" {
if .mval=.[max] then Erro... |
http://rosettacode.org/wiki/Define_a_primitive_data_type | Define a primitive data type | Demonstrate how to define a type that behaves like an integer but has a lowest valid value of 1 and a highest valid value of 10. Include all bounds checking you need to write, or explain how the compiler or interpreter creates those bounds checks for you.
| #MATLAB | MATLAB | classdef RingInt
properties
value
end
methods
%RingInt constructor
function theInt = RingInt(varargin)
if numel(varargin) == 0
theInt.value = 1;
elseif numel(varargin) > 1
error 'The RingInt constructor can''''t ta... |
http://rosettacode.org/wiki/Death_Star | Death Star |
Task
Display a region that consists of a large sphere with part of a smaller sphere removed from it as a result of geometric subtraction.
(This will basically produce a shape like a "death star".)
Related tasks
draw a sphere
draw a cuboid
draw a rotating cube
write language name in 3D ASCII
| #Phix | Phix | --
-- demo\rosetta\DeathStar.exw
-- ==========================
--
-- Translated from Go.
--
with javascript_semantics
include pGUI.e
constant title = "Death Star"
Ihandle dlg, canvas
cdCanvas cddbuffer, cdcanvas
function dot(sequence x, sequence y)
return sum(sq_mul(x,y))
end function
function normalize(sequenc... |
http://rosettacode.org/wiki/Day_of_the_week | Day of the week | A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
Task
In what years between 2008 and 2121 will the 25th of ... | #Action.21 | Action! |
Byte FUNC DayOfWeek(BYTE day, month CARD year BYTE century)
CARD weekday
BYTE ARRAY index=[0 3 2 5 0 3 5 1 4 6 2 4]
IF year < 100 THEN
year = year + century * 100
FI
IF year < 1753 THEN RETURN(7) FI
IF month < 3 THEN
year==-1
FI
month = index(month-1)
weekday=year + year/4 - year/10... |
http://rosettacode.org/wiki/Day_of_the_week | Day of the week | A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
Task
In what years between 2008 and 2121 will the 25th of ... | #Ada | Ada | with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Text_IO; use Ada.Text_IO;
procedure Yuletide is
begin
for Year in 2008..2121 loop
if Day_Of_Week (Time_Of (Year, 12, 25)) = Sunday then
Put_Line (Image (Time_Of (Year, 12, 25)));
end if;
end loop;
end Yuletide... |
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.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic data retrieval without meaningful analysis or patterns.
SQL Code Examples from Training Data
Retrieves raw SQL code examples for the SQL language, which is basic filtering that shows what data looks like but doesn't provide meaningful analysis or patterns.
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.