(*  Task : Generator/Exponential

    Version using the Seq module types, but transparently
*)

(*** Helper functions ***)

(* Generator type *)
type 'a gen = unit -> 'a node
and 'a node = Nil | Cons of 'a * 'a gen

(* Power function on integers *)
let power (base : int) (exp : int) : int =
    let rec helper exp acc =
        if exp = 0 then acc
        else helper (exp - 1) (base * acc)
    in
    helper exp 1

(* Take (at most) n from generator *)
let rec take (n : int) (gen : 'a gen) : 'a list =
    if n = 0 then []
    else
        match gen () with
        | Nil -> []
        | Cons (x, tl) -> x :: take (n - 1) tl

(* Stop existing generator at a given condition *)
let rec keep_while (p : 'a -> bool) (gen : 'a gen) : 'a gen = fun () ->
    match gen () with
    | Nil -> Nil
    | Cons (x, tl) ->
        if p x then Cons (x, keep_while p tl)
        else Nil

(* Drop the first n elements of a generator *)
let rec drop (n : int) (gen : 'a gen) : 'a gen =
    if n = 0 then gen
    else
    match gen () with
    | Nil -> (fun () -> Nil)
    | Cons (_, tl) -> drop (n - 1) tl

(* Filter based on predicate, lazily *)
let rec filter (p : 'a -> bool) (gen : 'a gen) : 'a gen = fun () ->
    match gen () with
    | Nil -> Nil
    | Cons (x, tl) ->
        if p x then Cons (x, filter p tl)
        else filter p tl ()

(* Is this value inside this generator? Does not terminate for infinite streams! *)
let rec mem (val_ : 'a) (gen : 'a gen) : bool =
    match gen () with
    | Nil -> false
    | Cons (x, tl) ->
        if x = val_ then true
        else mem val_ tl

(*** Task at hand ***)

(*  Create a function that returns a generation of the m'th powers of the positive integers
    starting from zero, in order, and without obvious or simple upper limit.
    (Any upper limit to the generator should not be stated in the source but should be down
    to factors such as the languages natural integer size limit or computational time/size).
*)
let power_gen k : int gen =
    let rec generator n () =
        Cons (power n k, generator (n + 1))
    in
    generator 0

(* Use it to create generators of squares and cubes *)
let squares = power_gen 2
let cubes = power_gen 3

(* Create a new generator that filters all cubes from the generator of squares. *)
let squares_no_cubes =
    let filter_p square =
        (* Get all cubes up to square *)
        let cubes_up_to_n2 = keep_while ((>=) square) cubes in
        not (mem square cubes_up_to_n2)
    in
    filter filter_p squares

(*** Output ***)

(* Drop the first 20 values from this last generator of filtered results, and then show the next 10 values. *)
let _ =
    squares_no_cubes |> drop 20 |> take 10


#include <stdlib.h>

#define N 26

int main() {
    unsigned char lower[N];

    for (size_t i = 0; i < N; i++) {
        lower[i] = i + 'a';
    }

    return EXIT_SUCCESS;
}


using System;
using System.Linq;

internal class Program
{
    private static void Main()
    {
        Console.WriteLine(String.Concat(Enumerable.Range('a', 26).Select(c => (char)c)));
    }
}


#include <string>
#include <numeric>

int main() {
    std::string lower(26,' ');

    std::iota(lower.begin(), lower.end(), 'a');
}


# gen_pow($m) creates and returns an anonymous subroutine that will
# generate and return the powers 0**m, 1**m, 2**m, ...
sub gen_pow {
    my $m = shift;
    my $e = 0;
    return sub { return $e++ ** $m; };
}

# gen_filter($g1, $g2) generates everything returned from $g1 that
# is not also returned from $g2. Both $g1 and $g2 must be references
# to subroutines that generate numbers in increasing order. gen_filter
# creates and returns an anonymous subroutine.
sub gen_filter {
    my($g1, $g2) = @_;
    my $v1;
    my $v2 = $g2->();
    return sub {
        for (;;) {
            $v1 = $g1->();
            $v2 = $g2->() while $v1 > $v2;
            return $v1 unless $v1 == $v2;
        }
    };
}

# Create generators.
my $squares = gen_pow(2);
my $cubes = gen_pow(3);
my $squares_without_cubes = gen_filter($squares, $cubes);

# Drop 20 values.
$squares_without_cubes->() for (1..20);

# Print 10 values.
my @answer;
push @answer, $squares_without_cubes->() for (1..10);
print "[", join(", ", @answer), "]\n";


(map char (range (int \a) (inc (int \z))))


alph = proc () returns (string)
    a: int := char$c2i('a')
    letters: array[char] := array[char]$predict(1,26)
    for i: int in int$from_to(0, 25) do
        array[char]$addh(letters, char$i2c(a + i))
    end
    return(string$ac2s(letters))
end alph

% test
start_up = proc ()
    stream$putl(stream$primary_output(), alph())
end start_up


identification division.
program-id. lower-case-alphabet-program.
data division.
working-storage section.
01  ascii-lower-case.
    05 lower-case-alphabet pic a(26).
    05 character-code      pic 999.
    05 loop-counter        pic 99.
procedure division.
control-paragraph.
    perform add-next-letter-paragraph varying loop-counter from 1 by 1
    until loop-counter is greater than 26.
    display lower-case-alphabet upon console.
    stop run.
add-next-letter-paragraph.
    add 97 to loop-counter giving character-code.
    move function char(character-code) to lower-case-alphabet(loop-counter:1).


(String.fromCharCode(x) for x in [97..122])


--
-- demo\rosetta\Generator_Exponential.exw
-- ======================================
--
without js -- tasks
bool terminate = false

atom res

procedure powers(integer p)
integer i=0
    while not terminate do
        res = power(i,p)
        task_suspend(task_self())
        task_yield()
        i += 1
    end while
end procedure

constant squares = task_create(powers,{2}),
         cubes   = task_create(powers,{3})

atom square, cube
task_schedule(cubes,1)
task_yield()
cube = res
for i=1 to 30 do
    while 1 do
        task_schedule(squares,1)
        task_yield()
        square = res
        while cube<square do
            task_schedule(cubes,1)
            task_yield()
            cube = res
        end while
        if square!=cube then exit end if
    end while
    if i>20 then
        ?square
    end if
end for

terminate = 1
{} = wait_key()


<?php
function powers($m) {
    for ($n = 0; ; $n++) {
        yield pow($n, $m);
    }
}

function filtered($s1, $s2) {
    while (true) {
        list($v, $f) = [$s1->current(), $s2->current()];
        if ($v > $f) {
            $s2->next();
            continue;
        } else if ($v < $f) {
            yield $v;
        }
        $s1->next();
    }
}

list($squares, $cubes) = [powers(2), powers(3)];
$f = filtered($squares, $cubes);
foreach (range(0, 19) as $i) {
    $f->next();
}
foreach (range(20, 29) as $i) {
    echo $i, "\t", $f->current(), "\n";
    $f->next();
}
?>


dim alphabet$ of 26
for i := 1 to 26
  alphabet$(i) := chr$(ord("a") - 1 + i)
endfor i
print alphabet$


(defvar *lower*
  (loop with a = (char-code #\a)
        for i below 26
        collect (code-char (+ a i))))


include "cowgol.coh";

# Generate the alphabet and store it at the given location
# It is assumed that there is enough space (27 bytes)
sub alph(buf: [uint8]): (out: [uint8]) is
    out := buf;
    var letter: uint8 := 'a';
    while letter <= 'z' loop
        [buf] := letter;
        letter := letter + 1;
        buf := @next buf;
    end loop;
    [buf] := 0;
end sub;

# Use the subroutine to print the alphabet
var buf: uint8[27]; # make room for the alphabet
print(alph(&buf as [uint8]));


import std.ascii: lowercase;

void main() {}


(de powers (M)
   (co (intern (pack 'powers M))
      (for (I 0 (inc 'I))
         (yield (** I M)) ) ) )

(de filtered (N M)
   (co 'filtered
      (let (V (powers N)  F (powers M))
         (loop
            (if (> V F)
               (setq F (powers M))
               (and (> F V) (yield V))
               (setq V (powers N)) ) ) ) ) )

(do 20 (filtered 2 3))
(do 10 (println (filtered 2 3)))


Generate: procedure options (main);   /* 27 October 2013 */
        declare j fixed binary;
        declare r fixed binary;

        /* Ignore the first 20 values */
        do j = 1 to 20;
           /* put edit (filter() ) (f(6)); */
           r = filter ();
        end;
        put skip;
        do j = 1 to 10;
           put edit (filter() ) (f(6));
        end;

/* filters out cubes from the result of the square generator. */
filter: procedure returns (fixed binary);
   declare n fixed binary static initial (-0);
   declare (i, j, m) fixed binary;

   do while ('1'b);
      m = squares();
      r = 0;
      do j = 1 to m;
         if m = cubes() then go to ignore;
      end;
      return (m);
ignore:
   end;
end filter;

squares: procedure returns (fixed binary);
        declare i fixed binary static initial (-0);

        i = i + 1;
        return (i**2);
end squares;

cubes: procedure returns (fixed binary);

        r = r + 1;
        return (r**3);
end cubes;

end Generate;


from itertools import islice, count

def powers(m):
    for n in count():
        yield n ** m

def filtered(s1, s2):
    v, f = next(s1), next(s2)
    while True:
        if v > f:
            f = next(s2)
            continue
        elif v < f:
            yield v
        v = next(s1)

squares, cubes = powers(2), powers(3)
f = filtered(squares, cubes)
print(list(islice(f, 20, 30)))


  [ ' [ this -1 peek
        this -2 peek **
        1 this tally
        done ]
     swap join
     0 join ]                         is expogen (   n --> [ )

  [ ' [ this temp put
        temp share -3 peek do
        dup temp share share = iff
          [ drop
            temp share -2 peek do
            temp take replace ] again
        [ dup temp share share > iff
            [ temp share -2 peek do
              temp share replace ]
            again ]
        temp release
        done ]
    unrot
    dip nested
    dup dip nested
    do 3 times join ]                 is taskgen ( [ [ --> [ )

  2 expogen
  3 expogen taskgen

  20 times [ dup do drop ]
  10 times [ dup do echo sp ]
  drop


program atoz;

var
  ch : char;

begin
  for ch in ['a'..'z'] do
  begin
    write(ch);
  end;
end.


/* Generate the lowercase alphabet and store it in a buffer */
proc alph(*char buf) *char:
    channel output text ch;
    char letter;
    open(ch, buf);
    for letter from 'a' upto 'z' do
        write(ch; letter)
    od;
    close(ch);
    buf
corp

/* Use the function to print the alphabet */
proc main() void:
    [27] char buf; /* one byte extra for the string terminator */
    writeln(alph(&buf[0]))
corp


0"abcdefghijklmnopqrstuvwxyz"        {store character values of string in cells 0..length of string-1}
26[$][^^-;,1-]#                      {Loop from 26-26 to 26-0, print the respective cell contents to STDOUT}


;; 1)
(define \a (first (string->unicode "a")))
(for/list ((i 25)) (unicode->string (+ i \a)))
    → (a b c d e f g h i j k l m n o p q r s t u v w x y)

;;2) using a sequence
(lib 'sequences)

(take ["a" .. "z"] 26)
    → (a b c d e f g h i j k l m n o p q r s t u v w x y z)

; or
(for/string ((letter ["a" .. "z"])) letter)
    → abcdefghijklmnopqrstuvwxyz


powers = function(m)
   {n = -1
    function()
       {n <<- n + 1
        n^m}}

noncubic.squares = local(
   {squares = powers(2)
    cubes = powers(3)
    cube = cubes()
    function()
       {square = squares()
        while (1)
           {if (square > cube)
               {cube <<- cubes()
                next}
            else if (square < cube)
               {return(square)}
            else
               {square = squares()}}}})

for (i in 1:20)
    noncubic.squares()
for (i in 1:10)
    message(noncubic.squares())


#lang racket

(require racket/generator)

;; this is a function that returns a powers generator, not a generator
(define (powers m)
  (generator ()
    (for ([n (in-naturals)]) (yield (expt n m)))))

(define squares (powers 2))
(define cubes   (powers 3))

;; same here
(define (filtered g1 g2)
  (generator ()
    (let loop ([n1 (g1)] [n2 (g2)])
      (cond [(< n1 n2) (yield n1) (loop (g1) n2)]
            [(> n1 n2) (loop n1 (g2))]
            [else (loop (g1) (g2))]))))

(for/list ([x (in-producer (filtered squares cubes) (lambda (_) #f))]
           [i 30] #:when (>= i 20))
  x)


sub powers($m) { $m XR** 0..* }

my @squares = powers(2);
my @cubes   = powers(3);

sub infix:<with-out> (@orig,@veto) {
    gather for @veto -> $veto {
        take @orig.shift while @orig[0] before $veto;
        @orig.shift if @orig[0] eqv $veto;
    }
}

say (@squares with-out @cubes)[20 ..^ 20+10].join(', ');


import extensions;
import system'collections;

singleton Alphabet : Enumerable
{
    Enumerator enumerator() = new Enumerator
    {
        char current;

        get() = current;

        bool next()
        {
            if (nil==current)
            {
                current := $97
            }
            else if (current != $122)
            {
                current := (current.toInt() + 1).toChar()
            }
            else
            {
                ^ false
            };

            ^ true
        }

        reset()
        {
            current := nil
        }

        enumerable() = self;
    };
}

public program()
{
    console.printLine(Alphabet)
}


iex(1)> Enum.to_list(?a .. ?z)
'abcdefghijklmnopqrstuvwxyz'
iex(2)> Enum.to_list(?a .. ?z) |> List.to_string
"abcdefghijklmnopqrstuvwxyz"


showAlphabet
=LAMBDA(az,
    ENUMFROMTOCHAR(
        MID(az, 1, 1)
    )(
        MID(az, 2, 1)
    )
)


let lower = ['a'..'z']

printfn "%A" lower


/*REXX program demonstrates how to use a  generator  (also known as an  iterator).      */
parse arg N .;   if N=='' |  N==","  then N=20   /*N  not specified?   Then use default.*/
@.=                                              /* [↓]  calculate squares,cubes,pureSq.*/
         do i=1  for N;   call Gsquare     i
                          call Gcube       i
                          call GpureSquare i     /*these are  cube─free  square numbers.*/
         end   /*i*/

     do k=1  for N;  @.pureSquare.k=;  end /*k*/ /*this is used to drop  1st  N  values.*/

w=length(N+10);               ps= 'pure square'  /*the width of the numbers;  a literal.*/

     do m=N+1  for 10;    say ps   right(m, w)":"     right(GpureSquare(m), 3*w)
     end       /*m*/
exit                                             /*stick a fork in it,  we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Gpower:      procedure expose @.;       parse arg x,p;   [email protected].pow.x.p
             if q\==''  then return q;  _=x**p;          @.pow.x.p=_
             return _
/*──────────────────────────────────────────────────────────────────────────────────────*/
Gsquare:     procedure expose @.;       parse arg x;     [email protected].square.x
             if q==''  then @.square.x=Gpower(x, 2)
             return @.square.x
/*──────────────────────────────────────────────────────────────────────────────────────*/
Gcube:       procedure expose @.;       parse arg x;     [email protected].cube.x
             if q==''  then @.cube.x=Gpower(x, 3)        [email protected].cube.x;     @.3pow._=1
             return @.cube.x
/*──────────────────────────────────────────────────────────────────────────────────────*/
GpureSquare: procedure expose @.;       parse arg x;     [email protected].pureSquare.x
             if q\==''  then return q
             #=0
                   do j=1  until #==x;  ?=Gpower(j, 2)        /*search for pure square. */
                   if @.3pow.?==1  then iterate               /*is it a power of three? */
                   #=#+1;               @.pureSquare.#=?      /*assign next pureSquare. */
                   end   /*j*/
             return @.pureSquare.x


# This solution cheats and uses only one generator!

def powers(m)
  return enum_for(__method__, m) unless block_given?
  0.step{|n| yield n**m}
end

def squares_without_cubes
  return enum_for(__method__) unless block_given?

  cubes = powers(3)
  c = cubes.next
  powers(2) do |s|
    c = cubes.next while c < s
    yield s unless c == s
  end
end

p squares_without_cubes.take(30).drop(20)
# p squares_without_cubes.lazy.drop(20).first(10)   # Ruby 2.0+


USING: spelling ; ! ALPHABET

ALPHABET print
0x61 0x7A [a,b] >string print
: russian-alphabet-without-io ( -- str ) 0x0430 0x0450 [a,b) >string ;
: russian-alphabet ( -- str ) 0x0451 6 russian-alphabet-without-io insert-nth ;
russian-alphabet print


: printit    26 0 do   [char] a I + emit   loop ;


  character(26) :: alpha
  integer :: i

  do i = 1, 26
    alpha(i:i) = achar(iachar('a') + i - 1)
  end do


use std::cmp::Ordering;
use std::iter::Peekable;

fn powers(m: u32) -> impl Iterator<Item = u64> {
    (0u64..).map(move |x| x.pow(m))
}

fn noncubic_squares() -> impl Iterator<Item = u64> {
    NoncubicSquares {
        squares: powers(2).peekable(),
        cubes: powers(3).peekable(),
    }
}

struct NoncubicSquares<T: Iterator<Item = u64>, U: Iterator<Item = u64>> {
    squares: Peekable<T>,
    cubes: Peekable<U>,
}

impl<T: Iterator<Item = u64>, U: Iterator<Item = u64>> Iterator for NoncubicSquares<T, U> {
    type Item = u64;
    fn next(&mut self) -> Option<u64> {
        loop {
            match self.squares.peek()?.cmp(self.cubes.peek()?) {
                Ordering::Equal => self.squares.next(),
                Ordering::Greater => self.cubes.next(),
                Ordering::Less => return self.squares.next(),
            };
        }
    }
}

fn main() {
    noncubic_squares()
        .skip(20)
        .take(10)
        .for_each(|x| print!("{} ", x));
    println!();
}


object Generators {
   def main(args: Array[String]): Unit = {
      def squares(n:Int=0):Stream[Int]=(n*n) #:: squares(n+1)
      def cubes(n:Int=0):Stream[Int]=(n*n*n) #:: cubes(n+1)

      def filtered(s:Stream[Int], c:Stream[Int]):Stream[Int]={
         if(s.head>c.head) filtered(s, c.tail)
         else if(s.head<c.head) Stream.cons(s.head, filtered(s.tail, c))
         else filtered(s.tail, c)
      }

      filtered(squares(), cubes()) drop 20 take 10 print
   }
}


(define (power-seq n)
  (let ((i 0))
    (lambda ()
      (set! i (+ 1 i))
      (expt i n))))

(define (filter-seq m n)
  (let* ((s1 (power-seq m)) (s2 (power-seq n))
			    (a 0) (b 0))
    (lambda ()
      (set! a (s1))
      (let loop ()
	(if (>= a b) (begin
		       (cond ((> a b) (set! b (s2)))
			     ((= a b) (set! a (s1))))
		       (loop))))
      a)))

(let loop ((seq (filter-seq 2 3)) (i 0))
  (if (< i 30)
    (begin
      (if (> i 20)
	(begin
	  (display (seq))
	  (newline))
	(seq))
      (loop seq (+ 1 i)))))


program lowerCaseAscii(input, output, stdErr);
const
	alphabet = ['a'..'z'];
begin
end.


#k 'a 'z ++ {|| {} print SPACE |} NL end


Public Sub Main()
Dim siCount As Short

For siCount = Asc("a") To Asc("z")
  Print Chr(siCount);
Next

End


// ExponentialGenerator.script

to initialize
	set my base to 0
	if my exponent is empty then set my exponent to 1 -- default if not given
end initialize

to handle nextValue
	add 1 to my base
	return my base to the power of my exponent
end nextValue


func gen_pow(m) {
    var e = 0;
    func { e++ ** m };
}

func gen_filter(g1, g2) {
    var v2 = g2.run;
    func {
        loop {
            var v1 = g1.run;
            while (v1 > v2) { v2 = g2.run };
            v1 == v2 || return v1;
        }
    }
}

# Create generators.
var squares = gen_pow(2);
var cubes = gen_pow(3);
var squares_without_cubes = gen_filter(squares, cubes);

# Drop 20 values.
20.times { squares_without_cubes() };

# Print 10 values.
var answer = [];
10.times { answer.append(squares_without_cubes()) };
say answer;


func powGen(m: Int) -> GeneratorOf<Int> {
  let power = Double(m)
  var cur: Double = 0
  return GeneratorOf { Int(pow(cur++, power)) }
}

var squares = powGen(2)
var cubes = powGen(3)

var nCube = cubes.next()

var filteredSqs = GeneratorOf<Int> {
  for var nSq = squares.next() ;; nCube = cubes.next() {
    if nCube > nSq {
      return nSq
    } else if nCube == nSq {
      nSq = squares.next()
    }
  }
}

extension GeneratorOf {
  func drop(n: Int) -> GeneratorOf<T> {
    var g = self
    for _ in 0..<n {g.next()}
    return GeneratorOf{g.next()}
  }
  func take(n: Int) -> GeneratorOf<T> {
    var (i, g) = (0, self)
    return GeneratorOf{++i > n ? nil : g.next()}
  }
}

for num in filteredSqs.drop(20).take(10) {
  print(num)
}

//529
//576
//625
//676
//784
//841
//900
//961
//1024
//1089


func loweralpha() string {
	p := make([]byte, 26)
	for i := range p {
		p[i] = 'a' + byte(i)
	}
	return string(p)
}


lower = ['a' .. 'z']

main = print lower


import Algorithms as algo;
import Text as text;

main() {
  print(
    "{}\n".format(
      text.character_class( text.CHARACTER_CLASS.LOWER_CASE_LETTER )
    )
  );
  print(
    "{}\n".format(
      algo.materialize(
        algo.map(
          algo.range( integer( 'a' ), integer( 'z' ) + 1 ),
          character
        ),
        string
      )
    )
  );
}


package require Tcl 8.6

proc powers m {
    yield
    for {set n 0} true {incr n} {
	yield [expr {$n ** $m}]
    }
}
coroutine squares powers 2
coroutine cubes powers 3
coroutine filtered apply {{s1 s2} {
    yield
    set f [$s2]
    set v [$s1]
    while true {
	if {$v > $f} {
	    set f [$s2]
	    continue
	} elseif {$v < $f} {
	    yield $v
	}
	set v [$s1]
    }
}} squares cubes

# Drop 20
for {set i 0} {$i<20} {incr i} {filtered}
# Take/print 10
for {} {$i<30} {incr i} {
    puts [filtered]
}


Public lastsquare As Long
Public nextsquare As Long
Public lastcube As Long
Public midcube As Long
Public nextcube As Long
Private Sub init()
    lastsquare = 1
    nextsquare = -1
    lastcube = -1
    midcube = 0
    nextcube = 1
End Sub

Private Function squares() As Long
    lastsquare = lastsquare + nextsquare
    nextsquare = nextsquare + 2
    squares = lastsquare
End Function

Private Function cubes() As Long
    lastcube = lastcube + nextcube
    nextcube = nextcube + midcube
    midcube = midcube + 6
    cubes = lastcube
End Function

Public Sub main()
    init
    cube = cubes
    For i = 1 To 30
        Do While True
            square = squares
            Do While cube < square
                cube = cubes
            Loop
            If square <> cube Then
                Exit Do
            End If
        Loop
        If i > 20 Then
            Debug.Print square;
        End If
    Next i
End Sub


   thru=: <. + [email protected](+*)@-~
   thru&.(a.&i.)/'az'
abcdefghijklmnopqrstuvwxyz


public class LowerAscii {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder(26);
        for (char ch = 'a'; ch <= 'z'; ch++)
            sb.append(ch);
        System.out.printf("lower ascii: %s, length: %s", sb, sb.length());
    }
}


(function (cFrom, cTo) {

  function cRange(cFrom, cTo) {
    var iStart = cFrom.charCodeAt(0);

    return Array.apply(
      null, Array(cTo.charCodeAt(0) - iStart + 1)
    ).map(function (_, i) {

      return String.fromCharCode(iStart + i);

    });
  }

  return cRange(cFrom, cTo);

})('a', 'z');


Module Program
    Iterator Function IntegerPowers(exp As Integer) As IEnumerable(Of Integer)
        Dim i As Integer = 0
        Do
            Yield CInt(Math.Pow(i, exp))
            i += 1
        Loop
    End Function

    Function Squares() As IEnumerable(Of Integer)
        Return IntegerPowers(2)
    End Function

    Function Cubes() As IEnumerable(Of Integer)
        Return IntegerPowers(3)
    End Function

    Iterator Function SquaresWithoutCubes() As IEnumerable(Of Integer)
        Dim cubeSequence = Cubes().GetEnumerator()
        Dim nextGreaterOrEqualCube As Integer = 0
        For Each curSquare In Squares()
            Do While nextGreaterOrEqualCube < curSquare
                cubeSequence.MoveNext()
                nextGreaterOrEqualCube = cubeSequence.Current
            Loop
            If nextGreaterOrEqualCube <> curSquare Then Yield curSquare
        Next
    End Function

    Sub Main()
        For Each x In From i In SquaresWithoutCubes() Skip 20 Take 10
            Console.WriteLine(x)
        Next
    End Sub
End Module


code ChOut=8, IntOut=11;

func Gen(M);            \Generate Mth powers of positive integers
int  M;
int  N, R, I;
[N:= [0, 0, 0, 0];      \provides own/static variables
R:= 1;
for I:= 1 to M do R:= R*N(M);
N(M):= N(M)+1;
return R;
];

func Filter;            \Generate squares of positive integers that aren't cubes
int  S, C;
[C:= [0];               \static variable = smallest cube > current square
repeat  S:= Gen(2);
        while S > C(0) do C(0):= Gen(3);
until   S # C(0);
return S;
];

int  I;
[for I:= 1 to 20 do Filter;                             \drop first 20 values
 for I:= 1 to 10 do [IntOut(0, Filter);  ChOut(0, ^ )]; \show next 10 values
]


"az" | explode | [range( .[0]; 1+.[1] )] | implode'


var powers = Fn.new { |m|
    var i = 0
    return Fn.new {
        var p = i.pow(m)
        i = i + 1
        return p
    }
}

var squaresNotCubes = Fn.new { |squares, cubes|
    var sq = squares.call()
    var cu = cubes.call()
    return Fn.new {
        var p
        while (true) {
            if (sq < cu) {
                p = sq
                sq = squares.call()
                return p
            }
            if (sq == cu) sq = squares.call()
            cu = cubes.call()
        }
    }
}

var squares = powers.call(2)
var cubes = powers.call(3)
var sqNotCu = squaresNotCubes.call(squares, cubes)
for (i in 0..29) {
    var p = sqNotCu.call()
    if (i > 19) System.write("%(p) ")
}
System.print()


fcn powers(m){ n:=0.0; while(1){vm.yield(n.pow(m).toInt()); n+=1} }
var squared=Utils.Generator(powers,2), cubed=Utils.Generator(powers,3);

fcn filtered(sg,cg){s:=sg.next(); c:=cg.next();
   while(1){
      if(s>c){c=cg.next(); continue;}
      else if(s<c) vm.yield(s);
      s=sg.next()
   }
}
var f=Utils.Generator(filtered,squared,cubed);
f.drop(20);
f.walk(10).println();


/* Generate the lower case alphabet with Jsish, assume ASCII */
var letterA = "a".charCodeAt(0);
var lowers = Array(26);
for (var i = letterA; i < letterA + 26; i++) {
    lowers[i - letterA] = Util.fromCharCode(i);
}
puts(lowers);
puts(lowers.join(''));
puts(lowers.length);

/*
=!EXPECTSTART!=
[ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ]
abcdefghijklmnopqrstuvwxyz
26
=!EXPECTEND!=
*/


@show collect('a':'z')
@show join('a':'z')


SWAP     CSECT ,                   control section start
         BAKR  14,0                stack caller's registers
         LR    12,15               entry point address to reg.12
         USING SWAP,12             use as base
         MVC   A,=C'5678____'      init field A
         MVC   B,=C'____1234'      init field B
         LA    2,L                 address of length field in reg.2
         WTO   TEXT=(2)            Write To Operator, results in:
*                                  +5678________1234
         XC    A,B                 XOR A,B
         XC    B,A                 XOR B,A
         XC    A,B                 XOR A,B. A holds B, B holds A
         WTO   TEXT=(2)            Write To Operator, results in:
*                                  +____12345678____
         PR    ,                   return to caller
         LTORG ,                   literals displacement
L        DC    H'16'               halfword containg decimal 16
A        DS    CL8                 field A, 8 bytes
B        DS    CL8                 field B, 8 bytes
         END   SWAP                program end


;swap X with Y
pha        ;push accumulator
   txa
   pha     ;push x
       tya
       pha ;push y
       pla
       tax ;pop y into x
   pla
   tay     ;pop x into y
pla        ;pop accumulator


EXG D0,D1 ;swap the contents of D0 and D1
EXG A0,A1 ;swap the contents of A0 and A1


// version 1.3.72

fun main() {
    val alphabet = CharArray(26) { (it + 97).toChar() }.joinToString("")

    println(alphabet)
}


1) We define code2char & char2code as primitives:

{script
LAMBDATALK.DICT["char2code"] = function() {
  var args = arguments[0].trim();
  return args.charCodeAt(0);
};

LAMBDATALK.DICT["code2char"] = function() {
  var args = arguments[0].trim();
  return String.fromCharCode(args);
};
}

2) and we use them:

{S.map code2char {S.serie {char2code a} {char2code z}}}
-> a b c d e f g h i j k l m n o p q r s t u v w x y z

{S.map code2char {S.serie {char2code 0} {char2code 9}}}
-> 0 1 2 3 4 5 6 7 8 9


        .ORIG      0x3000

        LD         R0,ASCIIa
        LD         R1,ASCIIz
        NOT        R1,R1

LOOP    OUT
        ADD        R0,R0,1
        ADD        R2,R0,R1
        BRN        LOOP

        HALT

ASCIIa  .FILL      0x61
ASCIIz  .FILL      0x7A


alphabet = []
repeat with i = 97 to 122
  alphabet.add(numtochar(i))
end repeat
put alphabet
-- ["a", "b", "c", ... , "x", "y", "z"]


xchg ax,bx    ;exchanges ax with bx

xchg ah,al    ;swap the high and low bytes of ax

;XCHG a register with memory
mov dx,0FFFFh
mov word ptr [ds:userRam],dx
mov si,offset userRam
mov ax,1234h
xchg ax,[si]   ;exchange ax with the value stored at userRam. Now, ax = 0FFFFh and the value stored at userRam = 1234h

;XCHG a register with a value on the stack.
mov ax,1234h
mov bx,4567h
push bx
push bp
mov bp,sp      ;using [sp] as an operand for XCHG will not work. You need to use bp instead.

xchg ax,[2+bp] ;exchanges AX with the value that was pushed from BX onto the stack. Now, AX = 4567h,
               ;and the entry on the stack just underneath the top of the stack is 1234h.


(defun swap (pair)
   (cons (cdr pair)
         (car pair)))

(let ((p (cons 1 2)))
  (cw "Before: ~x0~%After: ~x1~%" p (swap p)))


function getAlphabet ()
    local letters = {}
    for ascii = 97, 122 do table.insert(letters, string.char(ascii)) end
    return letters
end

local alpha = getAlphabet()
print(alpha[25] .. alpha[1] .. alpha[25])


\\ old style Basic, including a Binary.Or() function
Module OldStyle {
      10 LET A$=""
      20 FOR I=ASC("A") TO ASC("Z")
      30 LET A$=A$+CHR$(BINARY.OR(I, 32))
      40 NEXT I
      50 PRINT A$
}
CALL OldStyle


seq(StringTools:-Char(c), c = 97 .. 122);


-- user-defined function that returns the ASCII code for string character ch.
code(ch):=str2vec(ch)[0

-- number of lower-case ASCII characters
N:=26

-- range variable covering the relative indices of the lower-case characters within the ASCII character set (0 = 'a', 25 = 'z').
k:=0..N-1

-- ASCII code for letter 'a' (a=97 ).
a:=code("a")

-- iterate over k to produce a vector of lower case ASCII character codes
lcCodes[k:=k+a

-- convert vector to string of ordered ASCII lower-case characters.
lcString:=vec2str(lcCodes)
lcString="abcdefghijklmnopqrstuvwxyz"

-- Characters are indexable within the string; for example: substr(lcString,3,1)="d"


INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit

PROC Swap(BYTE POINTER ptr1,ptr2 INT size)
  BYTE tmp
  INT i

  FOR i=0 TO size-1
  DO
    tmp=ptr1^ ptr1^=ptr2^ ptr2^=tmp
    ptr1==+1 ptr2==+1
  OD
RETURN

PROC Main()
  BYTE b1=[13],b2=[56]
  INT i1=[65234],i2=[534]
  REAL r1,r2
  CHAR ARRAY s1="abcde",s2="XYZ"

  Put(125) PutE() ;clear the screen
  ValR("32.5",r1) ValR("-0.63",r2)

  Print("Swap bytes: ")
  PrintB(b1) Put(32) PrintB(b2) Print(" -> ")
  Swap(@b1,@b2,1)
  PrintB(b1) Put(32) PrintBE(b2)

  Print("Swap integers: ")
  PrintI(i1) Put(32) PrintI(i2) Print(" -> ")
  Swap(@i1,@i2,2)
  PrintI(i1) Put(32) PrintIE(i2)

  Print("Swap floats: ")
  PrintR(r1) Put(32) PrintR(r2) Print(" -> ")
  Swap(r1,r2,6)
  PrintR(r1) Put(32) PrintRE(r2)

  Print("Swap strings: ")
  Print(s1) Put(32) Print(s2) Print(" -> ")
  Swap(@s1,@s2,2)
  Print(s1) Put(32) PrintE(s2)
RETURN


generic
   type Swap_Type is private; -- Generic parameter
procedure Generic_Swap (Left, Right : in out Swap_Type);

procedure Generic_Swap (Left, Right : in out Swap_Type) is
   Temp : constant Swap_Type := Left;
begin
   Left := Right;
   Right := Temp;
end Generic_Swap;


start = 97;
lowerCaseLetters = Table[FromCharacterCode[start + i], {i, 0, 25}]


delete([], makelist(if(alphacharp(ascii(i))) then parse_string(ascii(i)) else [], i, 96, 122));


:- module gen_lowercase_ascii.
:- interface.

:- import_module io.

:- pred main(io::di, io::uo) is det.

:- implementation.

:- import_module char, int, list.

main(!IO) :-
    list.map(char.det_from_int, 0'a .. 0'z, Alphabet),
    io.print_line(Alphabet, !IO).

:- end_module gen_lowercase_ascii.


letters = []
for i in range(code("a"), code("z"))
    letters.push char(i)
end for

print letters


MODE GENMODE = STRING;

GENMODE v1:="Francis Gary Powers", v2:="Vilyam Fisher";

PRIO =:= = 1;

OP =:= = (REF GENMODE v1, v2)VOID: (
  GENMODE tmp:=v1; v1:=v2; v2:=tmp
);

v1 =:= v2;

print(("v1: ",v1, ", v2: ", v2, new line))


#include <flow.h>

DEF-MAIN(argv,argc)
   DIM(10) AS-INT-RAND( 10, random array )
   SET( single var, 0.5768 )

   PRNL( "SINGLE VAR: ", single var, "\nRANDOM ARRAY: ", random array )

   single var <-> random array

   PRNL( "SINGLE VAR: ", single var, "\nRANDOM ARRAY: ", random array )
END


LOWASCMIN
    set lowstr = ""
    for i = 97:1:122 set delim = $select(i=97:"",1:",") set lowstr = lowstr_delim_$char(i)
    write lowstr
    quit


lowercase = list()
for i in range(ord("a"), ord("z"))
     lowercase.append(chr(i))
end
println lowercase


/**
 <doc>Generate lower case ASCII, in Neko</doc>
**/

var slot = 25
var generated = $smake(slot + 1)
var lower_a = $sget("a", 0)

/* 'a'+25 down to 'a'+0 */
while slot >= 0 {
    $sset(generated, slot, slot + lower_a)
    slot -= 1
}

$print(generated, "\n")


lower_case_ascii = {code_char(c) : c in [97:123]};


# A slice just contains the first and last value
let alpha: Slice[char] = 'a'..'z'
echo alpha # (a: a, b: z)

# but can be used to check if a character is in it:
echo 'f' in alpha # true
echo 'G' in alpha # false

# A set contains all elements as a bitvector:
let alphaSet: set[char] = {'a'..'z'}
echo alphaSet # {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z}
echo 'f' in alphaSet # true
var someChars = {'a','f','g'}
echo someChars <= alphaSet # true

import sequtils
# A sequence:
let alphaSeq = toSeq 'a'..'z'
echo alphaSeq # @[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z]
echo alphaSeq[10] # k


(mac myswap (a b)
     (w/uniq gx
             `(let ,gx a
                   (= a b)
                   (= b ,gx))))

(with (a 1
       b 2)
      (myswap a b)
      (prn "a:" a #\Newline "b:" b))


swap: function [a,b]-> @[b,a]

c: 1
d: 2
print [c d]

[c,d]: swap c d
print [c d]


program lowerCaseAscii(input, output, stdErr);
var
	alphabet: set of char;
begin
	// as per ISO 7185, 'a'..'z' do not necessarily have to be contiguous
	alphabet := [
			'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
			'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
		];
end.


Swap(ByRef Left, ByRef Right)
{
    temp := Left
    Left := Right
    Right := temp
}


# syntax: GAWK -f GENERIC_SWAP.AWK
BEGIN {
    printf("%s version %s\n",ARGV[0],PROCINFO["version"])
    foo = 1
    bar = "a"
    printf("\n%s %s\n",foo,bar)
    rc = swap("foo","bar") # ok
    printf("%s %s %s\n",foo,bar,rc?"ok":"ng")
    printf("\n%s %s\n",foo,bar)
    rc = swap("FOO","BAR") # ng
    printf("%s %s %s\n",foo,bar,rc?"ok":"ng")
    exit(0)
}
function swap(a1,a2,  tmp) { # strings or numbers only; no arrays
    if (a1 in SYMTAB && a2 in SYMTAB) {
      if (isarray(SYMTAB[a1]) || isarray(SYMTAB[a2])) {
        return(0)
      }
      tmp = SYMTAB[a1]
      SYMTAB[a1] = SYMTAB[a2]
      SYMTAB[a2] = tmp
      return(1)
    }
    return(0)
}


string az = ""
    for ch='a' to 'z' do
        az &= ch
    end for
?az
?tagset('z','a')


0 tolist
'a' 'z' 2 tolist
for
    tochar 0 put
endfor
print


<?php
$lower = range('a', 'z');
var_dump($lower);
?>


main =>
  Alpha1 = (0'a..0'z).map(chr),
  println(Alpha1),
  Alpha2 = [chr(I) : I in 97..122],
  println(Alpha2).


@echo off
setlocal enabledelayedexpansion
set a=1
set b=woof
echo %a%
echo %b%
call :swap a b
echo %a%
echo %b%
goto :eof

:swap
set temp1=!%1!
set temp2=!%2!
set %1=%temp2%
set %2=%temp1%
goto :eof


F genfizzbuzz(factorwords, numbers)
   V sfactorwords = sorted(factorwords, key' p -> p[0])
   [String] lines
   L(num) numbers
      V words = sfactorwords.filter2((fact, wrd) -> (@num % fact) == 0).map2((fact, wrd) -> wrd).join(‘’)
      lines.append(I words != ‘’ {words} E String(num))
   R lines.join("\n")

print(genfizzbuzz([(5, ‘Buzz’), (3, ‘Fizz’), (7, ‘Baxx’)], 1..20))


(mapcar char (range (char "a") (char "z")))


gen: procedure options (main);  /* 7 April 2014. */
   declare 1 ascii union,
             2 letters (26) character (1),
             2 iletters(26) unsigned fixed binary (8),
           letter character(1);
   declare i fixed binary;

   letters(1), letter = lowercase('A');

   do i = 2 to 26;
      iletters(i) = iletters(i-1) + 1;
   end;
   put edit (letters) (a);

end gen;


100H: /* PRINT THE LOWERCASE LETTERS */

   /* CP/M BDOS SYSTEM CALL */
   BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5;END;
   /* CONSOLE OUTPUT ROUTINES */
   PR$STRING: PROCEDURE( S ); DECLARE S ADDRESS; CALL BDOS( 9, S ); END;

   /* TASK */
   DECLARE C BYTE, LC ( 27 )BYTE;
   DO C = 0 TO 25;
      LC( C ) = C + 32 + 'A';
   END;
   LC( LAST( LC ) ) = '$'; /* STRING TERMINATOR */
   CALL PR$STRING( .LC );

EOF


Declare
 sbAlphabet  varchar2(100);
Begin
  For nuI in 97..122 loop
      if sbAlphabet is null then
         sbAlphabet:=chr(nuI);
      Else
         sbAlphabet:=sbAlphabet||','||chr(nuI);
      End if;
  End loop;
  Dbms_Output.Put_Line(sbAlphabet);
End;


global a, b
a = "one"
b = "two"

print a, b
call swap(a, b)
print a, b
end

subroutine swap(a, b)
  temp = a : a = b : b = temp
end subroutine


      a = 1.23 : b = 4.56
      SWAP a,b
      PRINT a,b

      a$ = "Hello " : b$ = "world!"
      SWAP a$,b$
      PRINT a$,b$


DEFINE MAX_NUMBERS="200"
DEFINE MAX_LEN="20"
DEFINE MAX_FACTORS="5"
DEFINE PTR="CARD"

PROC PrintResult(BYTE max,n BYTE ARRAY factors PTR ARRAY texts)
  BYTE i,j,t
  BYTE ARRAY values(MAX_FACTORS)

  FOR j=0 TO n-1
  DO
    values(j)=1
  OD

  FOR i=1 TO max
  DO
    t=0
    FOR j=0 TO n-1
    DO
      IF values(j)=0 THEN
        t=1 Print(texts(j))
      FI
      values(j)==+1
      IF values(j)=factors(j) THEN
        values(j)=0
      FI
    OD
    IF t=0 THEN PrintB(i) FI
    Put(32)
  OD
RETURN

BYTE FUNC Find(CHAR ARRAY s CHAR c BYTE POINTER err)
  BYTE i

  FOR i=1 TO s(0)
  DO
    IF s(i)=c THEN
      err^=0 RETURN (i)
    FI
  OD
  err^=1
RETURN (0)

PROC Main()
  BYTE max,i,n,pos,err
  BYTE ARRAY factors(MAX_FACTORS)
  PTR ARRAY texts(MAX_FACTORS)
  CHAR ARRAY
    s(100),tmp(100),
    t0(MAX_LEN),t1(MAX_LEN),t2(MAX_LEN),
    t3(MAX_LEN),t4(MAX_LEN)

  texts(0)=t0 texts(1)=t1 texts(2)=t2
  texts(3)=t3 texts(4)=t4

  DO
    PrintF("Max number (1-%B): ",MAX_NUMBERS)
    max=InputB()
  UNTIL max>=1 AND max<=MAX_NUMBERS
  OD

  n=0
  DO
    PrintF("Number of rules (1-%B): ",MAX_FACTORS)
    n=InputB()
  UNTIL n>=1 AND n<=MAX_FACTORS
  OD

  FOR i=0 TO n-1
  DO
    DO
      PrintF("Rule #%B (number space text):",i+1)
      InputS(s)
      pos=Find(s,' ,@err)
      IF pos=1 OR pos=s(0) THEN
        err=1
      FI
      IF err=0 THEN
        SCopyS(tmp,s,1,pos-1)
        factors(i)=ValB(tmp)
        IF factors(i)<2 THEN
          err=1
        FI
        SCopyS(texts(i),s,pos+1,s(0))
      FI
    UNTIL err=0
    OD
  OD

  PutE()
  PrintResult(max,n,factors,texts)
RETURN


with Ada.Text_IO;              use Ada.Text_IO;
with Ada.Integer_Text_IO;      use Ada.Integer_Text_IO;
with Ada.Containers.Generic_Array_Sort;
with Ada.Strings.Unbounded;    use Ada.Strings.Unbounded;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;

procedure Main is
   type map_element is record
      Num  : Positive;
      Word : Unbounded_String;
   end record;

   type map_list is array (Positive range <>) of map_element;

   function "<" (Left, Right : map_element) return Boolean is
   begin
      return Left.Num < Right.Num;
   end "<";

   procedure list_sort is new Ada.Containers.Generic_Array_Sort
     (Index_Type => Positive, Element_Type => map_element,
      Array_Type => map_list);

   procedure general_fizz_buzz (max : Positive; words : in out map_list) is
      found : Boolean;
   begin
      list_sort (words);

      for i in 1 .. max loop
         found := False;
         for element of words loop
            if i mod element.Num = 0 then
               found := True;
               Put (element.Word);
            end if;
         end loop;
         if not found then
            Put (Item => i, Width => 1);
         end if;
         New_Line;
      end loop;
   end general_fizz_buzz;

   fizzy : map_list :=
     ((3, To_Unbounded_String ("FIZZ")), (7, To_Unbounded_String ("BAXX")),
      (5, To_Unbounded_String ("BUZZ")));

begin
   general_fizz_buzz (20, fizzy);
end Main;


BEGIN # generalised FizzBuzz                                        #
    # prompts for an integer, reads it and returns it               #
    PROC read integer = ( STRING prompt )INT:
         BEGIN
            print( ( prompt ) );
            INT result;
            read( ( result, newline ) );
            result
         END; # read integer #
    # prompts for a string, reads it and returns it                 #
    PROC read string = ( STRING prompt )STRING:
         BEGIN
            print( ( prompt ) );
            STRING result;
            read( ( result, newline ) );
            result
         END; # read string #
    # mode to hold a factor and associated text                     #
    MODE FBFACTOR = STRUCT( INT factor, STRING text );
    #===============================================================#
    # quicksort routine for the factors, from the Algol 68 uicksort #
    # task sample                                                   #
    #---------------------------------------------------------------#
    #--- Swap function ---#
    PROC swap = (REF[]FBFACTOR array, INT first, INT second) VOID:
    (   FBFACTOR temp  = array[first];
        array[first]  := array[second];
        array[second] := temp
    );
    #--- Quick sort 3 arg function ---#
    PROC quick = (REF[]FBFACTOR array, INT first, INT last) VOID:
    (   INT       smaller := first + 1, larger  := last;
        FBFACTOR  pivot   := array[first];
        WHILE smaller <= larger DO
            WHILE array[smaller] < pivot AND smaller < last  DO smaller +:= 1 OD;
            WHILE array[larger]  > pivot AND larger  > first DO larger  -:= 1 OD;
            IF smaller < larger THEN
                swap(array, smaller, larger);
                smaller +:= 1;
                larger  -:= 1
            ELSE
                smaller +:= 1
            FI
        OD;
        swap(array, first, larger);
        IF first < larger -1 THEN quick(array, first, larger-1) FI;
        IF last  > larger +1 THEN quick(array, larger+1, last)  FI
    );
    # comparison operators #
    OP < = ( FBFACTOR a, b )BOOL: factor OF a < factor OF b;
    OP > = ( FBFACTOR a, b )BOOL: factor OF a > factor OF b;
    #===============================================================#
    # get the maximum number to consider                            #
    INT max number = read integer( "Numbers reuired: " );
    # number of factors reuired                                     #
    INT max factor = 3;
    # get the factors and associated words                          #
    [ max factor ]FBFACTOR factors;
    FOR i TO max factor DO
        factor OF factors[ i ] := read integer( "Factor " + whole( i, 0 ) + ": " );
        text OF factors  [ i ] := read string( "Text for " + whole( factor OF factors[ i ], 0 ) + ": " )
    OD;
    # sort the factors into order                                   #
    quick( factors, 1, UPB factors );
    # play the game                                                 #
    FOR n TO max number DO
        STRING text := "";
        FOR factor TO max factor DO
            IF n MOD factor OF factors[ factor ] = 0 THEN text +:= text OF factors[ factor ] FI
        OD;
        IF text = "" THEN
            # no words applicable to n, just show the digits        #
            text := whole( n, 0 )
        FI;
        print( ( text, newline ) )
    OD
END


To run:
Start up.
Generate the lowercase ASCII alphabet giving a string.
Write the string on the console.
Wait for the escape key.
Shut down.

To generate the lowercase ASCII alphabet giving a string:
Put the little-a byte into a letter.
Loop.
Append the letter to the string.
If the letter is the little-z byte, exit.
Add 1 to the letter.
Repeat.


$asString = 97..122 | ForEach-Object -Begin {$asArray = @()} -Process {$asArray += [char]$_} -End {$asArray -join('')}
$asString


a_to_z(From, To, L) :-
	maplist(atom_codes, [From, To], [[C_From], [C_To]]),
	bagof([C], between(C_From, C_To, C), L1),
	maplist(atom_codes,L, L1).


# From the standard library:
from string import ascii_lowercase

# Generation:
lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]


beads 1 program 'Generic swap'

var
	a = [1 2 "Beads" 3 4]
	b = [1 2 "Language" 4 5]

calc main_init
	swap a[4] <=> b[3]


--------------------- GENERAL FIZZBUZZ -------------------

-- fizzEtc :: [(Int, String)] -> [Symbol]
on fizzEtc(rules)
    -- A non-finite sequence of fizzEtc symbols,
    -- as defined by the given list of rules.
    script numberOrNoise
        on |λ|(n)
            script ruleMatch
                on |λ|(a, mk)
                    set {m, k} to mk

                    if 0 = (n mod m) then
                        if integer is class of a then
                            k
                        else
                            a & k
                        end if
                    else
                        a
                    end if
                end |λ|
            end script

            foldl(ruleMatch, n, rules)
        end |λ|
    end script

    fmapGen(numberOrNoise, enumFrom(1))
end fizzEtc

--------------------------- TEST -------------------------
on run

    unlines(take(20, ¬
        fizzEtc({{3, "Fizz"}, {5, "Buzz"}, {7, "Baxx"}})))

end run

------------------------- GENERIC ------------------------

-- enumFrom :: Enum a => a -> [a]
on enumFrom(x)
    script
        property v : missing value
        on |λ|()
            if missing value is not v then
                set v to 1 + v
            else
                set v to x
            end if
            return v
        end |λ|
    end script
end enumFrom

-- fmapGen <$> :: (a -> b) -> Gen [a] -> Gen [b]
on fmapGen(f, gen)
    script
        property g : mReturn(f)
        on |λ|()
            set v to gen's |λ|()
            if v is missing value then
                v
            else
                g's |λ|(v)
            end if
        end |λ|
    end script
end fmapGen

-- foldl :: (a -> b -> a) -> a -> [b] -> a
on foldl(f, startValue, xs)
    tell mReturn(f)
        set v to startValue
        set lng to length of xs
        repeat with i from 1 to lng
            set v to |λ|(v, item i of xs, i, xs)
        end repeat
        return v
    end tell
end foldl

-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
    -- 2nd class handler function lifted into 1st class script wrapper.
    if script is class of f then
        f
    else
        script
            property |λ| : f
        end script
    end if
end mReturn

-- take :: Int -> [a] -> [a]
-- take :: Int -> String -> String
on take(n, xs)
    set ys to {}
    repeat with i from 1 to n
        set v to |λ|() of xs
        if missing value is v then
            return ys
        else
            set end of ys to v
        end if
    end repeat
    return ys
end take

-- unlines :: [String] -> String
on unlines(xs)
    -- A single string formed by the intercalation
    -- of a list of strings with the newline character.
    set {dlm, my text item delimiters} to ¬
        {my text item delimiters, linefeed}
    set s to xs as text
    set my text item delimiters to dlm
    s
end unlines


[ [] 26 times [ i^ char a + join ] ] constant is alpha$ ( --> $ )

alpha$ echo$


# From constants built into R:
letters

# Or generate the same with:
sapply(97:122, intToUtf8)


(define lowercase-letters (build-list 26 (lambda (x) (integer->char (+ x (char->integer #\a))))))


void swap(void *va, void *vb, size_t s)
{
  char t, *a = (char*)va, *b = (char*)vb;
  while(s--)
    t = a[s], a[s] = b[s], b[s] = t;
}


static void Swap<T>(ref T a, ref T b)
{
    T temp = a;
    a = b;
    b = temp;
}


maxNum: to :integer strip input "Set maximum number: "
facts: map 1..3 'x -> split.words strip input ~"Enter factor |x|: "
loop 1..maxNum 'i [
    printNum: true
    loop facts 'fact ->
        if zero? i % to :integer fact\0 [
            prints fact\1
            printNum: false
        ]
    print (printNum)? -> i -> ""
]


; Test parameters
max := 20, fizz := 3, buzz := 5, baxx := 7

Loop % max {
	output := ""
	if (Mod(A_Index, fizz) = 0)
		output .= "Fizz"
	if (Mod(A_Index, buzz) = 0)
		output .= "Buzz"
	if (Mod(A_Index, baxx) = 0)
		output .= "Baxx"
	if (output = "")
		FileAppend %A_Index%`n, *
	else
		FileAppend %output%`n, *
}


fn main() {
    // An iterator over the lowercase alpha's
    let ascii_iter = (0..26)
        .map(|x| (x + b'a') as char);

    println!("{:?}", ascii_iter.collect::<Vec<char>>());
}


object Abc extends App {
  val lowAlpha = 'a' to 'z' //That's all
  // Now several tests
  assert(lowAlpha.toSeq == Seq('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
    'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'),
    "No complete lowercase alphabet.")
  assert(lowAlpha.size == 26, "No 26 characters in alphabet")
  assert(lowAlpha.start == 'a', "Character 'a' not first char! ???")
  assert(lowAlpha.head == 'a', "Character 'a' not heading! ???")
  assert(lowAlpha.head == lowAlpha(0), "Heading char is not first char.")
  assert(lowAlpha contains 'n', "Character n not present.")
  assert(lowAlpha.indexOf('n') == 13, "Character n not on the 14th position.")
  assert(lowAlpha.last == lowAlpha(25), "Expected character (z)on the last and 26th pos.")

  println(s"Successfully completed without errors. [within ${
    scala.compat.Platform.currentTime - executionStart
  } ms]")
}


template<typename T> void swap(T& left, T& right)
{
  T tmp(left);
  left = right;
  right = tmp;
}


(defn swap [pair] (reverse pair))    ; returns a list
(defn swap [[a b]] '(b a))           ; returns a list
(defn swap [[a b]] [b a])            ; returns a vector


@echo off
rem input range
set /p "range=> "

rem input data (no error-checking)
set "data_ctr=0"
:input_loop
set "data="
set /p "data=> "
if "%data%" equ "" goto count
rem parsing data into 1-based pseudo-array
set /a "data_ctr+=1"
for /f "tokens=1-2 delims= " %%D in ("%data%") do (
   set "facto%data_ctr%=%%D"
   set "print%data_ctr%=%%E"
)
goto input_loop

rem perform fizzbuzz now
:count
setlocal enabledelayedexpansion
for /l %%C in (1,1,%range%) do (
   set "out="
   for /l %%X in (1,1,%data_ctr%) do (
      set /a "mod=%%C %% facto%%X"
      if !mod! equ 0 set "out=!out!!print%%X!"
   )
   if not defined out (echo %%C) else (echo !out!)
)
pause
exit /b 0


REM >genfizzb
INPUT "Maximum number: " max%
INPUT "Number of factors: " n%
DIM factors%(n% - 1)
DIM words$(n% - 1)
FOR i% = 0 TO n% - 1
    INPUT "> " factor$
    factors%(i%) = VAL(LEFT$(factor$, INSTR(factor$, " ") - 1))
    words$(i%) = MID$(factor$, INSTR(factor$, " ") + 1)
NEXT
FOR i% = 1 TO max%
    matched% = FALSE
    FOR j% = 0 TO n% - 1
        IF i% MOD factors%(j%) = 0 THEN
            PRINT words$(j%);
            matched% = TRUE
        ENDIF
    NEXT
    IF matched% THEN PRINT ELSE PRINT;i%
NEXT


GenFizzBuzz ← {factors‿words ← <˘⍉>𝕨 ⋄ (∾´∾⟜words/˜·(¬∨´)⊸∾0=factors|⊢)¨1+↕𝕩}


(map integer->char (iota 26 (char->integer #\a)))


$ include "seed7_05.s7i";

const proc: main is func
  local
    var string: lower is "";
    var char: ch is ' ';
  begin
    for ch range 'a' to 'z' do
      lower &:= ch;
    end for;
    writeln(lower);
  end func;


| asciiLower |
asciiLower := String new.
97 to: 122 do: [:asciiCode |
    asciiLower := asciiLower , asciiCode asCharacter
].
^asciiLower


&ALPHABET ('a' LEN(25)) . OUTPUT ;* Works in ASCII but not EBCDIC.


> i, 1..26
  d = [i+96,0]
  a[i] = #.str(d)
<
'now A is an array of letters a..z

> i, 1..#.size(a,1)
  #.output(a[i],#.rs)
<


function(swap var1 var2)
  set(_SWAP_TEMPORARY "${${var1}}")
  set(${var1} "${${var2}}" PARENT_SCOPE)
  set(${var2} "${_SWAP_TEMPORARY}" PARENT_SCOPE)
endfunction(swap)


       PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).

       PROCEDURE DIVISION.

       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.

       END PROGRAM SWAP-DEMO.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.


#include <stdio.h>
#include <stdlib.h>

struct replace_info {
    int n;
    char *text;
};

int compare(const void *a, const void *b)
{
    struct replace_info *x = (struct replace_info *) a;
    struct replace_info *y = (struct replace_info *) b;
    return x->n - y->n;
}

void generic_fizz_buzz(int max, struct replace_info *info, int info_length)
{
    int i, it;
    int found_word;

    for (i = 1; i < max; ++i) {
        found_word = 0;

        /* Assume sorted order of values in the info array */
        for (it = 0; it < info_length; ++it) {
            if (0 == i % info[it].n) {
                printf("%s", info[it].text);
                found_word = 1;
            }
        }

        if (0 == found_word)
            printf("%d", i);

        printf("\n");
    }
}

int main(void)
{
    struct replace_info info[3] = {
        {5, "Buzz"},
        {7, "Baxx"},
        {3, "Fizz"}
    };

    /* Sort information array */
    qsort(info, 3, sizeof(struct replace_info), compare);

    /* Print output for generic FizzBuzz */
    generic_fizz_buzz(20, info, 3);
    return 0;
}


using System;

public class GeneralFizzBuzz
{
    public static void Main()
    {
        int i;
        int j;
        int k;

        int limit;

        string iString;
        string jString;
        string kString;

        Console.WriteLine("First integer:");
        i = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("First string:");
        iString = Console.ReadLine();

        Console.WriteLine("Second integer:");
        j = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Second string:");
        jString = Console.ReadLine();

        Console.WriteLine("Third integer:");
        k = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Third string:");
        kString = Console.ReadLine();

        Console.WriteLine("Limit (inclusive):");
        limit = Convert.ToInt32(Console.ReadLine());

        for(int n = 1; n<= limit; n++)
        {
            bool flag = true;
            if(n%i == 0)
            {
                Console.Write(iString);
                flag = false;
            }

            if(n%j == 0)
            {
                Console.Write(jString);
                flag = false;
            }

            if(n%k == 0)
            {
                Console.Write(kString);
                flag = false;
            }
            if(flag)
                Console.Write(n);
            Console.WriteLine();
        }
    }
}


val lowercase_letters = List.tabulate (26, fn x => chr (x + ord #"a"));


// built-in: lowercase and uppercase letters
display c(alpha)
display c(ALPHA)

// generate a variable with the letters
clear
set obs 26
gen a=char(96+_n)

// or in Mata
mata
char(97..122)
end


(97..122).asAscii; // This example unfortunately throws an error
                   // for me when running it on version 3.10.2

// Apparently, the message 'asAscii' cannot be understood by
// an Array, so I used the message 'collect' to apply the function
// enclosed in {} to each individual element of the Array,
// passing them the message 'asAscii':

(97..122).collect({|asciiCode| asciiCode.asAscii});

// Instead of writing the ascii codes directly as numbers,
// one could also pass the chars a and z the message 'ascii' to convert
// them to ascii codes – perhaps making the code a bit clearer:

($a.ascii..$z.ascii).collect({|asciiCode| asciiCode.asAscii});

// both examples output [ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z ]


var letters = [Character]()

for i in 97...122 {
    let char = Character(UnicodeScalar(i))
    letters.append(char)
}


set alpha {a b c d e f g h i j k l m n o p q r s t u v w x y z}


<cfset temp = a />
<cfset a = b />
<cfset b = temp />


LDA 29
STA 31
LDA 30
STA 29
LDA 31
STA 30
STP
---
org 29
byte $0F
byte $E0
byte $00


#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

class pair  {
public:
    pair( int s, std::string z )            { p = std::make_pair( s, z ); }
    bool operator < ( const pair& o ) const { return i() < o.i(); }
    int i() const                           { return p.first; }
    std::string s() const                   { return p.second; }
private:
    std::pair<int, std::string> p;
};
void gFizzBuzz( int c, std::vector<pair>& v ) {
    bool output;
    for( int x = 1; x <= c; x++ ) {
        output = false;
        for( std::vector<pair>::iterator i = v.begin(); i != v.end(); i++ ) {
            if( !( x % ( *i ).i() ) ) {
                std::cout << ( *i ).s();
                output = true;
            }
        }
        if( !output ) std::cout << x;
        std::cout << "\n";
    }
}
int main( int argc, char* argv[] ) {
    std::vector<pair> v;
    v.push_back( pair( 7, "Baxx" ) );
    v.push_back( pair( 3, "Fizz" ) );
    v.push_back( pair( 5, "Buzz" ) );
    std::sort( v.begin(), v.end() );
    gFizzBuzz( 20, v );
    return 0;
}


decl int i
decl string low
for (set i (ord "a")) (< i (+ (ord "z") 1)) (inc i)
        set low (+ low (chr i))
end for
out low endl console


Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function


Function ASCII_Sequence(range)
	arr = Split(range,"..")
	For i = Asc(arr(0)) To Asc(arr(1))
		ASCII_Sequence = ASCII_Sequence & Chr(i) & " "
	Next
End Function

WScript.StdOut.Write ASCII_Sequence(WScript.Arguments(0))
WScript.StdOut.WriteLine


module main;
  integer i;

  initial begin
    for(i = 97; i <= 122; i=i+1)
    begin
      $write("%c ",i);
    end
      $finish ;
    end
endmodule


let lower = []
for c in range(0, 25)
   let lower += [nr2char(c + char2nr("a"))]
endfor


import std.algorithm: swap; // from Phobos standard library

// The D solution uses templates and it's similar to the C++ one:
void mySwap(T)(ref T left, ref T right) {
    auto temp = left;
    left = right;
    right = temp;
}

void main() {
    import std.stdio;

    int[] a = [10, 20];
    writeln(a);

    // The std.algorithm standard library module
    // contains a generic swap:
    swap(a[0], a[1]);
    writeln(a);

    // Using mySwap:
    mySwap(a[0], a[1]);
    writeln(a);
}


GENFIZBUZZ(MAX,WORDS,NUMBERS)
    ; loop until max, casting numeric to avoid errors
    for i=1:1:+MAX {
        set j = 1
        set descr = ""

        ; assumes NUMBERS parameter is comma-delimited
        while (j <= $length(NUMBERS,",")) {
            if ((i # $piece(NUMBERS,",",j,j)) = 0) {

                ; build descriptor string, again assuming comma-delimited WORDS parameter
                set descr = descr_$piece(WORDS,",",j,j)
            }

            set j = j + 1
        }    ; check list of numbers

        ; output values to screen
        write " "_$case(descr,"":i,:descr)
    }    ; next value until MAX

    quit


shared void run() {

	print("enter the max value");
	assert(exists maxLine = process.readLine(),
		exists max = parseInteger(maxLine));

	print("enter your number/word pairs
	       enter a blank line to stop");

	variable value divisorsToWords = map<Integer, String> {};

	while(true) {
		value line = process.readLine();
		assert(exists line);
		if(line.trimmed.empty) {
			break;
		}
		value pair = line.trimmed.split().sequence();
		if(exists first = pair.first,
			exists integer = parseInteger(first),
			exists word = pair[1]) {
			divisorsToWords = divisorsToWords.patch(map {integer -> word});
		}
	}

	value divisors = divisorsToWords.keys.sort(byIncreasing(Integer.magnitude));
	for(i in 1..max) {
		value builder = StringBuilder();
		for(divisor in divisors) {
			if(divisor.divides(i), exists word = divisorsToWords[divisor]) {
				builder.append(word);
			}
		}
		if(builder.empty) {
			print(i);
		} else {
			print(builder.string);
		}
	}
}


(defn fix [pairs]
  (map second pairs))

(defn getvalid [pairs n]
  (filter (fn [p] (zero? (mod n (first p))))
          (sort-by first pairs)))

(defn gfizzbuzz [pairs numbers]
  (interpose "\n"
             (map (fn [n] (let [f (getvalid pairs n)]
                            (if (empty? f)
                              n
                              (apply str
                                     (fix f)))))
                  numbers)))


(defun fizzbuzz (limit factor-words)
  (loop for i from 1 to limit
     if (assoc-if #'(lambda (factor) (zerop (mod i factor))) factor-words)
     do (loop for (factor . word) in factor-words
           when (zerop (mod i factor)) do (princ word)
           finally (fresh-line))
     else do (format t "~a~%" i)))

(defun read-factors (&optional factor-words)
  (princ "> ")
  (let ((input (read-line t nil)))
    (cond ((zerop (length input))
           (sort factor-words #'< :key #'car))
          ((digit-char-p (char input 0))
           (multiple-value-bind (n i) (parse-integer input :junk-allowed t)
             (read-factors (acons n (string-trim " " (subseq input i))
                                  factor-words))))
          (t (write-line "Invalid input.")
             (read-factors factor-words)))))

(defun main ()
  (loop initially (princ "> ")
     for input = (read-line t nil)
     until (and (> (length input) 0)
                (digit-char-p (char input 0))
                (not (zerop (parse-integer input :junk-allowed t))))
     finally (fizzbuzz (parse-integer input :junk-allowed t) (read-factors))))


Module LowerASCII

    Sub Main()
        Dim alphabets As New List(Of Char)
        For i As Integer = Asc("a") To Asc("z")
            alphabets.Add(Chr(i))
        Next
        Console.WriteLine(String.Join("", alphabets.ToArray))
    End Sub

End Module


fn loweralpha() string {
    mut p := []u8{len: 26}
    for i in 97..123 {
        p[i-97] = u8(i)
    }
    return p.bytestr()
}


(module $lowercase

  (import "wasi_unstable" "fd_write"
    (func $fd_write (param i32 i32 i32 i32) (result i32))
  )

  (memory 1)
  (export "memory" (memory 0))

  (func $main (export "_start")
    (local $i i32)

    (i32.store (i32.const 0) (i32.const 8))   ;; offset to start of string
    (i32.store (i32.const 4) (i32.const 27))  ;; string length

    (set_local $i (i32.const 0))
    (loop
      ;; mem[i+8] = i+97
      (i32.store (i32.add (get_local $i) (i32.const 8)) (i32.add (get_local $i) (i32.const 97)))
      ;; i = i+1
      (set_local $i (i32.add (get_local $i) (i32.const 1)))
      ;; if i < 26 then loop
      (br_if 0 (i32.lt_s (get_local $i) (i32.const 26)))
    )
    ;; append a newline
    (i32.store (i32.add (get_local $i) (i32.const 8)) (i32.const 10))

    ;; write to stdout
    (call $fd_write
      (i32.const 1)  ;; output stream to write to (1 == stdout)
      (i32.const 0)  ;; memory location containing string offset and length
      (i32.const 1)  ;; number of strings to write
      (i32.const 40) ;; location in memory to write number of bytes written
    )
    drop
  )
)


$ a1 = 123
$ a2 = "hello"
$ show symbol a*
$ gosub swap
$ show symbol a*
$ exit
$
$ swap:
$  t = a1
$  a1 = a2
$  a2 = t
$ return


procedure Swap_T(var a, b: T);
var
  temp: T;
begin
  temp := a;
  a := b;
  b := temp;
end;


counter = 0

puts "Enter a maximum number:"
limit = gets

puts "Enter the first integer for factoring:"
first_int = gets
puts "Enter the name of the first integer:"
first_int_name = gets

puts "Enter the second integer for factoring:"
second_int = gets
puts "Enter the name of the second integer:"
second_int_name = gets

puts "Enter the third integer for factoring:"
third_int = gets
puts "Enter the name of the third integer:"
third_int_name = gets

if (limit &&
   first_int &&
   second_int &&
   third_int &&
   first_int_name &&
   second_int_name &&
   third_int_name)
  limit = limit.chomp.to_i
  first_int = first_int.chomp.to_i
  second_int = second_int.chomp.to_i
  third_int = third_int.chomp.to_i
  while limit > counter
    counter += 1
    if (counter % first_int) == 0 && (counter % second_int) == 0 && (counter % third_int) == 0
      puts first_int_name + second_int_name + third_int_name
    elsif (counter % first_int) == 0 && (counter % second_int) == 0
      puts first_int_name + second_int_name
    elsif (counter % first_int) == 0
      puts first_int_name
    elsif (counter % second_int) == 0
      puts second_int_name
    elsif (counter % third_int) == 0
      puts third_int_name
    else
      puts counter
    end
  end
else
  exit
end


import core.stdc.stdlib;
import std.stdio;

void main() {
    int limit;
    write("Max number (>0): ");
    readf!"%d\n"(limit);
    if (limit <= 0) {
        writeln("The max number to consider must be greater than zero.");
        exit(1);
    }

    int terms;
    write("Terms (>0): ");
    readf!"%d\n"(terms);
    if (terms <= 0) {
        writeln("The number of terms to consider must be greater than zero.");
        exit(1);
    }

    int[] factors = new int[terms];
    string[] words = new string[terms];

    for (int i=0; i<terms; ++i) {
        write("Factor ", i+1, " and word: ");
        readf!"%d %s\n"(factors[i], words[i]);
        if (factors[i] <= 0) {
            writeln("The factor to consider must be greater than zero.");
            exit(1);
        }
    }

    foreach(n; 1..limit+1) {
        bool print = true;

        for (int i=0; i<terms; ++i) {
            if (n % factors[i] == 0) {
                write(words[i]);
                print = false;
            }
        }

        if (print) {
            writeln(n);
        } else {
            writeln();
        }
    }
}


var alpha = []
for (c in 97..122) alpha.add(String.fromByte(c))
System.print(alpha.join())


(defun ascii-lower ()
    (defun add-chars (x y s)
        (if (<= x y)
            (add-chars (+ x 1) y (string-append s (string (integer->char x))))
            s))
    (add-chars 97 122 ""))


	org &8000
	ld a,'a'               ;data
	ld b,26                ;loop counter
	ld hl,Alphabet         ;destination
loop:
	ld (hl),a              ;store "a" into ram
	inc a                  ;next letter
	inc hl                 ;next storage byte
	djnz loop              ;repeat until 26 letters were stored.

	call Monitor_MemDump   ;hexdumps the specified address and bytecount to screen - created by Keith S. of Chibiakumas
	byte 32                ;number of bytes to display
	word Alphabet          ;address to dump from

	ret                    ;return to basic

Alphabet:
       ds 26,0                 ;reserve 26 bytes of ram, init all to zero.


def swap(&left, &right) {
  def t := left
  left := right
  right := t
}


;; 1)
;; a macro will do it, as shown in Racket (same syntax)
(define-syntax-rule (swap a b)
    (let ([tmp a])
    (set! a b)
    (set! b tmp)))

(define A 666)
(define B "simon")
(swap A B)
A → "simon"
B → 666

;; 2)
;; The list-swap! function allows to swap two items inside a list, regardless of their types
;; This physically alters the list

(define L ' ( 1 2 3 4 🎩 ))
(list-swap! L 1 ' 🎩 )
    → (🎩 2 3 4 1)


defmodule General do
  def fizzbuzz(input) do
    [num | nwords] = String.split(input)
    max = String.to_integer(num)
    dict = Enum.chunk(nwords, 2) |> Enum.map(fn[n,word] -> {String.to_integer(n),word} end)
    Enum.each(1..max, fn i ->
      str = Enum.map_join(dict, fn {n,word} -> if rem(i,n)==0, do: word end)
      IO.puts if str=="", do: i, else: str
    end)
  end
end

input = """
105
3 Fizz
5 Buzz
7 Baxx
"""
General.fizzbuzz(input)


%%% @doc Implementation of General FizzBuzz
%%% @see https://rosettacode.org/wiki/General_FizzBuzz
-module(general_fizzbuzz).
-export([run/2]).
-spec run(N :: pos_integer(), Factors :: list(tuple())) -> ok.

fizzbuzz(N, [], []) ->
    integer_to_list(N);
fizzbuzz(_, [], Result) ->
    lists:flatten(lists:reverse(Result));
fizzbuzz(N, Factors, Result) ->
    [{Factor, Output}|FactorsRest] = Factors,

    NextResult = case N rem Factor of
        0 -> [Output|Result];
        _ -> Result
    end,

    fizzbuzz(N, FactorsRest, NextResult).

run(N, Factors) ->
    lists:foreach(
        fun(S) -> io:format("~s~n", [S]) end,
        [fizzbuzz(X, Factors, []) || X <- lists:seq(1, N)]
    ).


USING: assocs combinators.extras io kernel math math.parser
math.ranges prettyprint sequences splitting ;
IN: rosetta-code.general-fizzbuzz

: prompt ( -- str ) ">" write readln ;

: get-factor ( -- seq )
    prompt " " split first2 [ string>number ] dip
    { } 2sequence ;

: get-input ( -- assoc n )
    prompt string>number [1,b] [ get-factor ] thrice
    { } 3sequence swap ;

: fizzbuzz ( assoc n -- )
    swap dupd [ drop swap mod 0 = ] with assoc-filter
    dup empty? [ drop . ] [ nip values concat print ] if ;

: main ( -- ) get-input [ fizzbuzz ] with each ;

MAIN: main


["a".."z"]  // lasy list
["a".."z"].walk() //-->L("a","b","c","d","e",...
"a".toAsc().pump(26,List,"toChar")  // another way to create the list
"a".toAsc().pump(26,String,"toChar")  // create a string
   //-->"abcdefghijklmnopqrstuvwxyz"
Utils.Helpers.lowerLetters  // string const


const std = @import("std");

pub fn main() !void {
    const cnt_lower = 26;
    var lower: [cnt_lower]u8 = undefined;
    comptime var i = 0;
    inline while (i < cnt_lower) : (i += 1)
        lower[i] = i + 'a';

    const stdout_wr = std.io.getStdOut().writer();
    for (lower) |l|
        try stdout_wr.print("{c} ", .{l});
    try stdout_wr.writeByte('\n');
}


import extensions;

swap(ref object v1, ref object v2)
{
    var tmp := v1;

    v1 := v2;
    v2 := tmp
}

public program()
{
    var n := 2;
    var s := "abc";

    console.printLine(n," ",s);

    swap(ref n, ref s);

    console.printLine(n," ",s)
}


(defun swap (a-sym b-sym)
  "Swap values of the variables given by A-SYM and B-SYM."
  (let ((a-val (symbol-value a-sym)))
    (set a-sym (symbol-value b-sym))
    (set b-sym a-val)))
(swap 'a 'b)


\ gfb.fs - generalized fizz buzz
: times		( xt n -- )
	BEGIN dup WHILE
		1- over swap 2>r execute 2r>
	REPEAT
	2drop
;
\ 'Domain Specific Language' compiling words
\ -- First  comment: stack-effect at compile-time
\ -- Second comment: stack efect of compiled sequence
: ]+[		( u ca u -- ) ( u f -- u f' )
	2>r >r	]
			]] over [[
	r>  		]] literal mod 0= IF [[
	2r> 		]] sliteral type 1+ THEN [ [[
;
: ]fb		( -- xt ) ( u f -- u+1 )
	]] IF space ELSE dup u. THEN 1+ ; [[
;
: fb[		( -- ) ( u -- u 0  ;'u' is START-NUMBER )
	:noname  0 ]] literal [ [[
;
\ Usage: START-NUMBER COMPILING-SEQUENCE U times drop ( INCREASED-NUBER )
\ Example:
\ 1 fb[ 3 s" fizz" ]+[ 5 s" buzz" ]+[ 7 s" dizz" ]+[ ]fb 40 times drop


' version 01-03-2018
' compile with: fbc -s console

Dim As UInteger f(), factor, c, i, n
Dim As Integer max
Dim As String w(), word
Dim As boolean flag

Do
    Input "Enter maximum number, if number < 1 then the program wil end ", max
    If max < 1 Then Exit Do

    Print
    While c = 0 Or c > max
        Input "Total number of factors ", c
    Wend
    c -= 1
    ReDim f(c), w(c)

    Print
    For i = 0 To c
        Input "Enter factor and word, separated by a comma ", factor, word
        f(i) = factor
        w(i) = word
    Next

    While flag = FALSE
        flag = TRUE
        For n = 0 To c-1
            For i = 1 To c
                If f(n) > f(i) Then
                    flag = FALSE
                    Swap f(n), f(i)
                    Swap w(n), w(i)
                End If
            Next
        Next
    Wend

    For n = 1 To max
        flag = FALSE
        For i = 0 To c
            If n Mod f(i) = 0 Then
                flag = TRUE
                Print w(i);
            End If
        Next
        Print IIf(flag , "", Str(n))
    Next

    Exit Do
Loop

' empty keyboard buffer
While Inkey <> "" : Wend
Print : Print "hit any key to end program"
Sleep
End


package main

import (
	"fmt"
)

const numbers = 3

func main() {

	//using the provided data
	max := 20
	words := map[int]string{
		3: "Fizz",
		5: "Buzz",
		7: "Baxx",
	}
	keys := []int{3, 5, 7}
	divisible := false
	for i := 1; i <= max; i++ {
		for _, n := range keys {
			if i % n == 0 {
				fmt.Print(words[n])
				divisible = true
			}
		}
		if !divisible {
			fmt.Print(i)
		}
		fmt.Println()
		divisible = false
	}

}


include std/console.e -- for display

object x = 3.14159
object y = "Rosettacode"

{y,x} = {x,y}

display("x is now []",{x})
display("y is now []",{y})


def log = ''
(1..40).each {Integer value -> log +=(value %3 == 0) ? (value %5 == 0)? 'FIZZBUZZ\n':(value %7 == 0)? 'FIZZBAXX\n':'FIZZ\n'
                                    :(value %5 == 0) ? (value %7 == 0)? 'BUZBAXX\n':'BUZZ\n'
                                    :(value %7 == 0) ?'BAXX\n'
                                    :(value+'\n')}
println log


fizz :: (Integral a, Show a) => a -> [(a, String)] -> String
fizz a xs
    | null result = show a
    | otherwise   = result
    where result = concatMap (fizz' a) xs
          fizz' a (factor, str)
              | a `mod` factor == 0 = str
              | otherwise           = ""

main = do
    line <- getLine
    let n = read line
    contents <- getContents
    let multiples = map (convert . words) $ lines contents
    mapM_ (\ x -> putStrLn $ fizz x multiples) [1..n]
    where convert [x, y] = (read x, y)


public class FizzBuzz {

    public static void main(String[] args) {
        Sound[] sounds = {new Sound(3, "Fizz"), new Sound(5, "Buzz"),  new Sound(7, "Baxx")};
        for (int i = 1; i <= 20; i++) {
            StringBuilder sb = new StringBuilder();
            for (Sound sound : sounds) {
                sb.append(sound.generate(i));
            }
            System.out.println(sb.length() == 0 ? i : sb.toString());
        }
    }

    private static class Sound {
        private final int trigger;
        private final String onomatopoeia;

        public Sound(int trigger, String onomatopoeia) {
            this.trigger = trigger;
            this.onomatopoeia = onomatopoeia;
        }

        public String generate(int i) {
            return i % trigger == 0 ? onomatopoeia : "";
        }

    }

}


function fizz(d, e) {
  return function b(a) {
    return a ? b(a - 1).concat(a) : [];
  }(e).reduce(function (b, a) {
    return b + (d.reduce(function (b, c) {
      return b + (a % c[0] ? "" : c[1]);
    }, "") || a.toString()) + "\n";
  }, "");
}


MODULE Genericswap
  IMPLICIT NONE

  INTERFACE Swap
    MODULE PROCEDURE Swapint, Swapreal, Swapstring
  END INTERFACE

CONTAINS

  SUBROUTINE Swapint(a, b)
    INTEGER, INTENT(IN OUT) :: a, b
    INTEGER :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapint

  SUBROUTINE Swapreal(a, b)
    REAL, INTENT(IN OUT) :: a, b
    REAL :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapreal

  SUBROUTINE Swapstring(a, b)
    CHARACTER(*), INTENT(IN OUT) :: a, b
    CHARACTER(len(a)) :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapstring
END MODULE Genericswap

PROGRAM EXAMPLE
  USE Genericswap
  IMPLICIT NONE
  INTEGER :: i1 = 1, i2 = 2
  REAL :: r1 = 1.0, r2 = 2.0
  CHARACTER(3) :: s1="abc", s2="xyz"

  CALL Swap(i1, i2)
  CALL Swap(r1, r2)
  CALL Swap(s1, s2)

  WRITE(*,*) i1, i2   ! Prints 2 and 1
  WRITE(*,*) r1, r2   ! Prints 2.0 and 1.0
  WRITE(*,*) s1, s2   ! Prints xyz and abc
END PROGRAM EXAMPLE


{$ifdef fpc}{$mode delphi}{$H+}{$endif}
{ note this is compiled with delphi mode but will only compile in Free Pascal }
{ Delphi doesn't support this syntax                                          }
procedure swap<T>(var left,right:T);
var
  temp:T;
begin
  temp:=left;
  left:=right;
  right:=temp;
end;
var
  a:string = 'Test';
  b:string = 'me';
begin
  writeln(a:6,b:6);
  swap<string>(a,b);
  writeln(a:6,b:6);
end.


function fizzbuzz(triggers :: Vector{Tuple{Int, ASCIIString}}, upper :: Int)
    for i = 1 : upper
        triggered = false

        for trigger in triggers
            if i % trigger[1] == 0
                triggered = true
                print(trigger[2])
            end
        end

        !triggered && print(i)
        println()
    end
end

print("Enter upper limit:\n> ")
upper = parse(Int, readline())

triggers = Tuple{Int, ASCIIString}[]
print("Enter factor/string pairs (space delimited; ^D when done):\n> ")
while (r = readline()) != ""
    input = split(r)
    push!(triggers, (parse(Int, input[1]), input[2]))
    print("> ")
end

println("EOF\n")
fizzbuzz(triggers, upper)


fun main(args: Array<String>) {

    //Read the maximum number, set to 0 if it couldn't be read
    val max = readLine()?.toInt() ?: 0
    val words = mutableMapOf<Int, String>()

    //Read input three times for a factor and a word
    (1..3).forEach {
        readLine()?.let {
            val tokens = it.split(' ')
            words.put(tokens[0].toInt(), tokens[1])
        }
    }

    //Sort the words so they will be output in arithmetic order
    val sortedWords = words.toSortedMap()

    //Find the words with matching factors and print them, print the number if no factors match
    for (i in 1..max) {
        val wordsToPrint = sortedWords.filter { i % it.key == 0 }.map { it.value }
        if (wordsToPrint.isNotEmpty()) {
            wordsToPrint.forEach { print(it) }
            println()
        }
        else
            println(i)
    }
}


function generalisedFizzBuzz m, f1, f2, f3
    put f1 & cr & f2 & cr & f3 into factors
    sort factors ascending numeric
    repeat with i = 1 to m
        put false into flag
        if i mod (word 1 of line 1 of factors) = 0 then
            put word 2 of line 1 of factors after fizzbuzz
            put true into flag
        end if
        if i mod (word 1 of line 2 of factors) = 0 then
            put word 2 of line 2 of factors after fizzbuzz
            put true into flag
        end if
        if i mod (word 1 of line 3 of factors) = 0 then
            put word 2 of line 3 of factors after fizzbuzz
            put true into flag
        end if
        if flag is false then put i after fizzbuzz
        put cr after fizzbuzz
    end repeat
    return fizzbuzz
end generalisedFizzBuzz


function genFizz (param)
  local response
  print("\n")
  for n = 1, param.limit do
    response = ""
    for i = 1, 3 do
      if n % param.factor[i] == 0 then
        response = response .. param.word[i]
      end
    end
    if response == "" then print(n) else print(response) end
  end
end

local param = {factor = {}, word = {}}
param.limit = io.read()
for i = 1, 3 do
  param.factor[i], param.word[i] = io.read("*number", "*line")
end
genFizz(param)


' FB 1.05.0
#Macro Declare_Swap(T)
Sub Swap_##T(ByRef t1 As T, ByRef t2 As T)
  Dim temp As T = t2
  t2 = t1
  t1 = temp
End Sub
#EndMacro

Dim As Integer i, j
i = 1 : j = 2

Declare_Swap(Integer) ' expands the macro
Swap_Integer(i, j)
Print i, j

Dim As String s, t
s = "Hello" : t = "World"

Declare_Swap(String)
Swap_String(s, t)
Print s, t

Print
Print "Press any key to exit"
Sleep


window 1, @"Generic Swap", (0,0,480,270)

text ,,,,, 60

long        i, j
double      x, y
CFStringRef a, b

i = 1059 : j = 62
print i, j
swap i, j
print i, j

print

x = 1.23 : y = 4.56
print x, y
swap x, y
print x, y

print

a = @"Hello" : b = @"World!"
print a, b
swap a, b
print a, b

HandleEvents


Public Sub Main()
Dim vA As Variant = " World"
Dim vB As Variant = 1

Swap vA, vB

Print vA; vB

End


findNum := proc(str) #help parse input
	local i;
	i := 1:
	while (true) do
		if (StringTools:-IsAlpha(str[i])) then
			return i-2:
		end if:
		i := i+1:
	end do:
end proc:
path := "input.txt";
input := readline(path):
T := table():
maxnum := parse(input):
while (true) do
	input := readline(path):
	if input = 0 then break; end if:
	pos := findNum(input):
	num := parse(input[..pos]):
	T[num] := input[pos+2..]:
end do:
for i from 1 to maxnum do
	factored := false:
	for j in [indices(T)] do
		if i mod j[1] = 0 then
			factored := true:
			printf(T[j[1]]);
		end if:
	end do:
	if (not factored) then printf("%d", i): end if:
	printf("\n");
end do:


factorWords = {}

maxNr = val(input("Max number? "))

while true
	factorInput = input("Factor? ")
	if factorInput == "" then break
	// Split input
	parts = factorInput.split(" ")
	factor = val(parts[0])
	word = parts[1]
	// Assign factor/word
	factorWords[factor] = word
end while

for nr in range(1,maxNr)
	matchingWords = ""
	for factor in factorWords.indexes
		if nr % factor == 0 then
			matchingWords = matchingWords + factorWords[factor]
		end if
	end for
	if matchingWords then print matchingWords else print nr
end for


MODULE GeneralFizzBuzz;
FROM Conversions IMPORT StrToInt;
FROM FormatString IMPORT FormatString;
FROM Terminal IMPORT Write,WriteString,WriteLn,ReadChar;

TYPE
    Word = ARRAY[0..63] OF CHAR;

PROCEDURE WriteInt(i : INTEGER);
VAR buf : Word;
BEGIN
    FormatString("%i", buf, i);
    WriteString(buf);
END WriteInt;

PROCEDURE ReadInt() : INTEGER;
VAR
    buf : ARRAY[0..9] OF CHAR;
    c : CHAR;
    i : INTEGER;
BEGIN
    i := 0;
    LOOP
        c := ReadChar();
        IF (c=0C) OR (i>9) THEN
            BREAK
        ELSIF (c=012C) OR (c=015C) THEN
            WriteLn;
            buf[i] := 0C;
            BREAK
        ELSIF (c<'0') OR (c>'9') THEN
            Write(c);
            buf[i] := 0C;
            BREAK
        ELSE
            Write(c);
            buf[i] := c;
            INC(i)
        END
    END;
    StrToInt(buf, i);
    RETURN i
END ReadInt;

PROCEDURE ReadLine() : Word;
VAR
    buf : Word;
    i : INTEGER;
    c : CHAR;
BEGIN
    i := 0;
    WHILE i<HIGH(buf) DO
        c := ReadChar();
        IF (c=0C) OR (c=012C) OR (c=015C) THEN
            WriteLn;
            buf[i] := 0C;
            BREAK
        ELSE
            Write(c);
            buf[i] := c;
            INC(i)
        END
    END;
    RETURN buf;
END ReadLine;

VAR
    i,max : INTEGER;
    fa,fb,fc : INTEGER;
    wa,wb,wc : Word;
    done : BOOLEAN;
BEGIN
    max := ReadInt();

    fa := ReadInt();
    wa := ReadLine();
    fb := ReadInt();
    wb := ReadLine();
    fc := ReadInt();
    wc := ReadLine();

    FOR i:=1 TO max DO
        done := FALSE;
        IF i MOD fa = 0 THEN
            done := TRUE;
            WriteString(wa);
        END;
        IF i MOD fb = 0 THEN
            done := TRUE;
            WriteString(wb);
        END;
        IF i MOD fc = 0 THEN
            done := TRUE;
            WriteString(wc);
        END;
        IF NOT done THEN
            WriteInt(i)
        END;
        WriteLn;
    END;

    ReadChar
END GeneralFizzBuzz.


factors = {}
words   = {}

// get the max number
print ">"
max = int(input())

// get the factors
inp = " "
while inp != ""
	print ">"
	inp = input()
	if " " in inp
		factors.append(int(split(inp, " ")[0]))
		words.append(split(inp, " ")[1])
	end
end

// output all the numbers
for i in range(1, max)
	foundfactor = false
	for j in range(0, len(factors) - 1)
		if (i % factors[j]) = 0
			foundfactor = true
			print words[j]
		end
	end
	j = 0

	if !foundfactor
		print i
	end
	println
end


import parseutils, strutils, algorithm

type FactorAndWord = tuple[factor:int, word: string]

var number: int
var factorAndWords: array[3, FactorAndWord]

#custom comparison proc for the FactorAndWord type
proc customCmp(x,y: FactorAndWord): int =
  if x.factor < y.factor:
    -1
  elif x.factor > y.factor:
    1
  else:
    0

echo "Enter max number:"
var input = readLine(stdin)
discard parseInt(input, number)

for i in 0..2:

  echo "Enter a number and word separated by space:"
  var input = readLine(stdin)

  var tokens = input.split
  discard parseInt(tokens[0], factorAndWords[i].factor)
  factorAndWords[i].word = tokens[1]

#sort factors in ascending order
sort(factorAndWords, customCmp)

#implement fiz buz
for i in 1..number:
  var written = false;
  for item in items(factorAndWords):
    if i mod item.factor == 0 :
      write(stdout, item.word)
      written = true
  if written :
    write(stdout, "\n")
  else :
    writeLine(stdout, i)


(* Task : General_FizzBuzz *)

(*
	The FizzBuzz problem, but
	generalized to have any strings, at any steps,
	up to any number of iterations.
*)

let gen_fizz_buzz (n : int) (l : (int * string) list) : unit =
  let fold_f i (acc : bool) (k, s) =
    if i mod k = 0
    then (print_string s; true)
    else acc
  in
  let rec helper i =
    if i > n
    then ()
    else
      let any_printed = List.fold_left (fold_f i) false l in
      begin
        (if not any_printed
         then print_int i);
        print_newline ();
        helper (succ i)
      end
  in
  helper 1
;;

(*** Output ***)

gen_fizz_buzz 20 [(3, "Fizz"); (5, "Buzz"); (7, "Baxx")] ;;


`Swap Vars &.a. &.b.'
{
    new .temp.
    .temp. = \.word2.
    \.word2. = \.word3.
    \.word3. = .temp.
    delete .temp.
}

.foo. = 123
.bar. = 456
Swap Vars &.foo. &.bar.

show .foo. " " .bar.
# prints "456 123"


PROCEDURE Swap( /*@*/v1, /*@*/v2 )
   LOCAL xTmp
   xTmp := v1
   v1 := v2
   v2 := xTmp
   RETURN


#!bin/usr/perl
use 5.020;
use strict;
use warnings;

#Get a max number from the user
say("Please enter the maximum possible multiple. ");
my $max = <STDIN>;

#Get the factors from the user
my @factors = ();
my $buffer;
say("Now enter the first factor and its associated word. Ex: 3 Fizz ");
chomp($buffer = <STDIN>);
push @factors, $buffer;
say("Now enter the second factor and its associated word. Ex: 5 Buzz ");
chomp($buffer = <STDIN>);
push @factors, $buffer;
say("Now enter the third factor and its associated word. Ex: 7 Baxx ");
chomp($buffer = <STDIN>);
push @factors, $buffer;

#Counting from 1 to max
for(my $i = 1; $i <= $max; $i++)
{
    #Create a secondary buffer as well as set the original buffer to the current index
    my $oBuffer;
    $buffer = $i;
    #Run through each element in our array
    foreach my $element (@factors)
    {
        #Look for white space
        $element =~ /\s/;
        #If the int is a factor of max, append it to oBuffer as a string to be printed
        if($i % substr($element, 0, @-) == 0)
        {
            $oBuffer = $oBuffer . substr($element, @+ + 1, length($element));
            #This is essentially setting a flag saying that at least one element is a factor
            $buffer = "";
        }
    }
    #If there are any factors for that number, print their words. If not, print the number.
    if(length($buffer) > 0)
    {
        print($buffer . "\n");
    }
    else
    {
        print($oBuffer . "\n");
    }
}


procedure main()
   x := 1
   y := 2
   x :=: y
   write(x," ",y)
   # swap that will reverse if surrounding expression fails
   if x <-> y & x < y then write(x, " ", y)
end


pro swap, a, b
  c = temporary(a)
  a = temporary(b)
  b = temporary(c)
end


100 DEF SWAP(REF A,REF B)
110   LET T=A:LET A=B:LET B=T
120 END DEF
130 LET A=1:LET B=2
140 PRINT A,B
150 CALL SWAP(A,B)
160 PRINT A,B


procedure general_fizz_buzz(integer lim, sequence words, facts)
    for i=1 to lim do
        string word = ""
        for j=1 to length(facts) do
            if remainder(i,facts[j])=0 then
                word &= words[j]
            end if
        end for
        if length(word)=0 then
            word = sprintf("%d",i)
        end if
        printf(1,"%s\n",{word})
    end for
end procedure
general_fizz_buzz(20, {"Fizz","Buzz","Baxx"}, {3,5,7})


<?php

$max = 20;
$factor = array(3 => 'Fizz', 5 => 'Buzz', 7 => 'Jazz');

for ($i = 1 ; $i <= $max ; $i++) {
    $matched = false;
    foreach ($factor AS $number => $word) {
        if ($i % $number == 0) {
            echo $word;
            $matched = true;
        }
    }
    echo ($matched ? '' : $i), PHP_EOL;
}

?>


interactive =>
   print("> "),
   MaxNum = read_int(),
   Map = new_map(),
   print("> "),
   while (Line = read_line(), Line != "")
     [N,V] = split(Line),
     Map.put(N.to_int,V),
     print("> ")
   end,
   general_fizzbuzz(MaxNum,Map.to_list.sort),
   nl.

general_fizzbuzz(N,L) =>
  FB = [I.to_string : I in 1..N],
  foreach(I in 1..N)
    Vs = [V : K=V in L, I mod K == 0].join(''),
    if Vs != "" then
      FB[I] := Vs
    end
  end,
  println([F : F in FB].join(" ")).


   (<2 4) C. 2 3 5 7 11 13 17 19
2 3 11 7 5 13 17 19
   (<0 3)&C.&.;:'Roses are red. Violets are blue.'
Violets are red. Roses are blue.


class Pair<T> {
    T first;
    T second;
}
public static <T> void swap(Pair<T> p) {
   T temp = p.first;
   p.first = p.second;
   p.second = temp;
}


function swap(arr) {
  var tmp = arr[0];
  arr[0] = arr[1];
  arr[1] = tmp;
}


(de general (N Lst)
   (for A N
      (prinl
         (or
            (extract
               '((L)
                  (and (=0 (% A (car L))) (cdr L)) )
               Lst )
            A ) ) ) )

(general 20 '((3 . Fizz) (5 . Buzz) (7 . Baxx)))


$limit = 20
$data  = @("3 Fizz","5 Buzz","7 Baxx")
	#An array with whitespace as the delimiter
	#Between the factor and the word

for ($i = 1;$i -le $limit;$i++){
	$outP = ""
	foreach ($x in $data){
		$data_split = $x -split " "	#Split the "<factor> <word>"
		if (($i % $data_split[0]) -eq 0){
			$outP += $data_split[1]	#Append the <word> to outP
		}
	}
	if(!$outP){	#Is outP equal to NUL?
		Write-HoSt $i
	} else {
		Write-HoSt $outP
	}
}


def genfizzbuzz(factorwords, numbers):
    # sort entries by factor
    factorwords.sort(key=lambda factor_and_word: factor_and_word[0])
    lines = []
    for num in numbers:
        words = ''.join(word for factor, word in factorwords if (num % factor) == 0)
        lines.append(words if words else str(num))
    return '\n'.join(lines)

if __name__ == '__main__':
    print(genfizzbuzz([(5, 'Buzz'), (3, 'Fizz'), (7, 'Baxx')], range(1, 21)))


jq -n '1 as $a | 2 as $b | $a as $tmp | $b as $a | $tmp as $b | [$a,$b]'


// version 1.1

fun <T> swap(t1: T, t2: T) = Pair(t2, t1)

fun main(args: Array<String>) {
    var a = 3
    var b = 4
    val c = swap(a, b) // infers that swap<Int> be used
    a = c.first
    b = c.second
    println("a = $a")
    println("b = $b")
    var d = false
    var e = true
    val f = swap(d, e) // infers that swap<Boolean> be used
    d = f.first
    e = f.second
    println("d = $d")
    println("e = $e")
}


genFizzBuzz <- function(n, ...)
{
  args <- list(...)
  #R doesn't like vectors of mixed types, so c(3, "Fizz") is coerced to c("3", "Fizz"). We must undo this.
  #Treating "[[" as if it is a function is a bit of R's magic. You can treat it like a function because it actually is one.
  factors <- as.integer(sapply(args, "[[", 1))
  words <- sapply(args, "[[", 2)
  sortedPermutation <- sort.list(factors)#Required by the task: We must go from least factor to greatest.
  factors <- factors[sortedPermutation]
  words <- words[sortedPermutation]
  for(i in 1:n)
  {
    isFactor <- i %% factors == 0
    print(if(any(isFactor)) paste0(words[isFactor], collapse = "") else i)
  }
}
genFizzBuzz(105, c(3, "Fizz"), c(5, "Buzz"), c(7, "Baxx"))
genFizzBuzz(105, c(5, "Buzz"), c(9, "Prax"), c(3, "Fizz"), c(7, "Baxx"))


#lang racket/base

(define (get-matches num factors/words)
  (for*/list ([factor/word (in-list factors/words)]
              [factor (in-value (car factor/word))]
              [word (in-value (cadr factor/word))]
              #:when (zero? (remainder num factor)))
    word))

(define (gen-fizzbuzz from to factors/words)
  (for ([num (in-range from to)])
    (define matches (get-matches num factors/words))
    (displayln (if (null? matches)
                  (number->string num)
                  (apply string-append matches)))))

(gen-fizzbuzz 1 21 '((3 "Fizz")
                     (5 "Buzz")
                     (7 "Baxx")))


# General case implementation of a "FizzBuzz" class.
# Defaults to standard FizzBuzz unless a new schema is passed in.
class FizzBuzz {
    has $.schema is rw = < 3 Fizz 5 Buzz >.hash;
    method filter (Int $this) {
        my $fb;
        for $.schema.sort: { +.key } -> $p { $fb ~= $this %% +$p.key ?? $p.value !! ''};
        return $fb || $this;
    }
}

# Sub implementing the specific requirements of the task.
sub GeneralFizzBuzz (Int $upto, @schema?) {
    my $ping = FizzBuzz.new;
    $ping.schema = @schema.hash if @schema;
    map { $ping.filter: $_ }, 1 .. $upto;
}

# The task
say 'Using: 20 ' ~ <3 Fizz 5 Buzz 7 Baxx>;
.say for GeneralFizzBuzz(20, <3 Fizz 5 Buzz 7 Baxx>);

say '';

# And for fun
say 'Using: 21 ' ~ <2 Pip 4 Squack 5 Pocketa 7 Queep>;
say join ', ', GeneralFizzBuzz(21, <2 Pip 4 Squack 5 Pocketa 7 Queep>);


1) using an Immediately Invoked Function Expression:
{{lambda {:x :y} :y :x} hello world}
-> world hello

2) or user defined function
{def swap {lambda {:x :y} :y :x}}
-> swap

3) applied on words (which can be numbers)
{swap hello world}
-> world hello

{swap hello brave new world}
-> brave new hello world

{swap {cons hello brave} {cons new world}}
-> (new world) (hello brave)


var .abc = [1, 2, 3]
var .def = [5, 6, 7]

.abc[3], .def[3] = .def[3], .abc[3]

writeln .abc
writeln .def


define swap(a, b) => (: #b, #a)

local(a) = 'foo'
local(b) = 42

local(a,b) = swap(#a, #b)
stdoutnl(#a)
stdoutnl(#b)


Red ["FizzBuzz"]

nmax: to-integer ask "Max number: "
while ["" <> trim rule: ask "New rule (empty to end): "][
	append rules: [] load rule
]
repeat n nmax [
	res: copy ""
	foreach [x blah] rules [
		if n % x = 0 [append res blah]
	]
	print either empty? res [n] [res]
]
halt


/*REXX program shows a generalized  FizzBuzz  program:  #1 name1    #2 name2   ···      */
parse arg h $                                    /*obtain optional arguments from the CL*/
if h='' | h=","  then h= 20                      /*Not specified?  Then use the default.*/
if $='' | $=","  then $= "3 Fizz 5 Buzz 7 Baxx"  /* "      "         "   "   "     "    */
factors= words($) % 2                            /*determine number of factors to use.  */

  do i=1  by 2  for factors                      /*parse the number factors to be used. */
  #.i=word($, i);   @.i=word($, i+1)             /*obtain the factor and its  "name".   */
  end   /*i*/

  do j=1  for h;                    z=           /*traipse through the numbers to   H.  */
                  do k=1  by 2  for factors      /*   "       "     " factors  in   J.  */
                  if j//#.k==0  then z= z || @.k /*Is it a factor?  Then append it to Z.*/
                  end   /*k*/                    /* [↑]  Note:  the factors may be zero.*/
  say word(z j, 1)                               /*display the number  or  its factors. */
  end                  /*j*/                     /*stick a fork in it,  we're all done. */


limit = 20
for n = 1 to limit
    if n % 3 = 0 see "" + n + " = " + "Fizz"+ nl
    but n % 5 = 0 see "" + n + " = " + "Buzz" + nl
    but n % 7 = 0 see "" + n + " = " + "Baxx" + nl
    else see "" + n + " = " + n + nl ok
next


def general_fizzbuzz(text)
  num, *nword = text.split
  num = num.to_i
  dict = nword.each_slice(2).map{|n,word| [n.to_i,word]}
  (1..num).each do |i|
    str = dict.map{|n,word| word if i%n==0}.join
    puts str.empty? ? i : str
  end
end

text = <<EOS
20
3 Fizz
5 Buzz
7 Baxx
EOS

general_fizzbuzz(text)


to swap :s1 :s2
  local "t
  make "t thing :s1
  make :s1 thing :s2
  make :s2 :t
end

make "a 4
make "b "dog
swap "a "b        ; pass the names of the variables to swap
show list :a :b  ; [dog 4]


on swap (x, y)
  return "tmp="&x&RETURN&x&"="&y&RETURN&y&"=tmp"
end


put "first" into a1
put "last" into b2
swap a1,b2
put a1 && b2

command swap @p1, @p2
    put p2 into p3
    put p1 into p2
    put p3 into p1
end swap


use std::io;
use std::io::BufRead;

fn parse_entry(l: &str) -> (i32, String) {
    let params: Vec<&str> = l.split(' ').collect();

    let divisor = params[0].parse::<i32>().unwrap();
    let word = params[1].to_string();
    (divisor, word)
}

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines().map(|l| l.unwrap());

    let l = lines.next().unwrap();
    let high = l.parse::<i32>().unwrap();

    let mut entries = Vec::new();
    for l in lines {
        if &l == "" { break }
        let entry = parse_entry(&l);
        entries.push(entry);
    }

    for i in 1..(high + 1) {
        let mut line = String::new();
        for &(divisor, ref word) in &entries {
            if i % divisor == 0 {
                line = line + &word;
            }
        }
        if line == "" {
            println!("{}", i);
        } else {
            println!("{}", line);
        }
    }
}


$ scala GeneralFizzBuzz.scala
20
3 Fizz
5 Buzz
7 Baxx
^D

1
2
Fizz
4
Buzz
Fizz
Baxx
8
Fizz
Buzz
11
Fizz
13
Baxx
FizzBuzz
16
17
Fizz
19
Buzz