kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Generator_Exponential
C: #include <inttypes.h>	
#include <stdlib.h>	
#include <stdio.h>	

#include <libco.h>	




struct gen64 {
	cothread_t giver;	
	cothread_t taker;	
	int64_t given;
	void (*free)(struct gen64 *);
	void *garbage;
};


inline void
yield64(struct gen64 *gen, int64_t value)
{
	gen->given = value;
	co_switch(gen->taker);
}


inline int64_t
next64(struct gen64 *gen)
{
	gen->taker = co_active();
	co_switch(gen->giver);
	return gen->given;
}

static void
gen64_free(struct gen64 *gen)
{
	co_delete(gen->giver);
}

struct gen64 *entry64;


inline void
gen64_init(struct gen64 *gen, void (*entry)(void))
{
	if ((gen->giver = co_create(4096, entry)) == NULL) {
		
		fputs("co_create: Cannot create cothread\n", stderr);
		exit(1);
	}
	gen->free = gen64_free;
	entry64 = gen;
}




void
powers(struct gen64 *gen, int64_t m)
{
	int64_t base, exponent, n, result;

	for (n = 0;; n++) {
		
		base = n;
		exponent = m;
		for (result = 1; exponent != 0; exponent >>= 1) {
			if (exponent & 1) result *= base;
			base *= base;
		}
		yield64(gen, result);
	}
	
}


#define ENTRY(name, code) static void name(void) { code; }
ENTRY(enter_squares, powers(entry64, 2))
ENTRY(enter_cubes, powers(entry64, 3))

struct swc {
	struct gen64 cubes;
	struct gen64 squares;
	void (*old_free)(struct gen64 *);
};

static void
swc_free(struct gen64 *gen)
{
	struct swc *f = gen->garbage;
	f->cubes.free(&f->cubes);
	f->squares.free(&f->squares);
	f->old_free(gen);
}


void
squares_without_cubes(struct gen64 *gen)
{
	struct swc f;
	int64_t c, s;

	gen64_init(&f.cubes, enter_cubes);
	c = next64(&f.cubes);

	gen64_init(&f.squares, enter_squares);
	s = next64(&f.squares);

	
	f.old_free = gen->free;
	gen->garbage = &f;
	gen->free = swc_free;

	for (;;) {
		while (c < s)
			c = next64(&f.cubes);
		if (c != s)
			yield64(gen, s);
		s = next64(&f.squares);
	}
	
}

ENTRY(enter_squares_without_cubes, squares_without_cubes(entry64))


int
main()
{
	struct gen64 gen;
	int i;

	gen64_init(&gen, enter_squares_without_cubes);

	for (i = 0; i < 20; i++)
		next64(&gen);
	for (i = 0; i < 9; i++)
		printf("%" PRId64 ", ", next64(&gen));
	printf("%" PRId64 "\n", next64(&gen));

	gen.free(&gen); 
	return 0;
}

C#: using System;
using System.Collections.Generic;
using System.Linq;

static class Program {
    static void Main() {
        Func<int, IEnumerable<int>> ms = m => Infinite().Select(i => (int)Math.Pow(i, m));
        var squares = ms(2);
        var cubes = ms(3);
        var filtered = squares.Where(square => cubes.First(cube => cube >= square) != square);
        var final = filtered.Skip(20).Take(10);
        foreach (var i in final) Console.WriteLine(i);
    }

    static IEnumerable<int> Infinite() {
        var i = 0;
        while (true) yield return i++;
    }
}
Task: Generator_Exponential
C: #include <inttypes.h>	
#include <stdlib.h>	
#include <stdio.h>	

#include <libco.h>	




struct gen64 {
	cothread_t giver;	
	cothread_t taker;	
	int64_t given;
	void (*free)(struct gen64 *);
	void *garbage;
};


inline void
yield64(struct gen64 *gen, int64_t value)
{
	gen->given = value;
	co_switch(gen->taker);
}


inline int64_t
next64(struct gen64 *gen)
{
	gen->taker = co_active();
	co_switch(gen->giver);
	return gen->given;
}

static void
gen64_free(struct gen64 *gen)
{
	co_delete(gen->giver);
}

struct gen64 *entry64;


inline void
gen64_init(struct gen64 *gen, void (*entry)(void))
{
	if ((gen->giver = co_create(4096, entry)) == NULL) {
		
		fputs("co_create: Cannot create cothread\n", stderr);
		exit(1);
	}
	gen->free = gen64_free;
	entry64 = gen;
}




void
powers(struct gen64 *gen, int64_t m)
{
	int64_t base, exponent, n, result;

	for (n = 0;; n++) {
		
		base = n;
		exponent = m;
		for (result = 1; exponent != 0; exponent >>= 1) {
			if (exponent & 1) result *= base;
			base *= base;
		}
		yield64(gen, result);
	}
	
}


#define ENTRY(name, code) static void name(void) { code; }
ENTRY(enter_squares, powers(entry64, 2))
ENTRY(enter_cubes, powers(entry64, 3))

struct swc {
	struct gen64 cubes;
	struct gen64 squares;
	void (*old_free)(struct gen64 *);
};

static void
swc_free(struct gen64 *gen)
{
	struct swc *f = gen->garbage;
	f->cubes.free(&f->cubes);
	f->squares.free(&f->squares);
	f->old_free(gen);
}


void
squares_without_cubes(struct gen64 *gen)
{
	struct swc f;
	int64_t c, s;

	gen64_init(&f.cubes, enter_cubes);
	c = next64(&f.cubes);

	gen64_init(&f.squares, enter_squares);
	s = next64(&f.squares);

	
	f.old_free = gen->free;
	gen->garbage = &f;
	gen->free = swc_free;

	for (;;) {
		while (c < s)
			c = next64(&f.cubes);
		if (c != s)
			yield64(gen, s);
		s = next64(&f.squares);
	}
	
}

ENTRY(enter_squares_without_cubes, squares_without_cubes(entry64))


int
main()
{
	struct gen64 gen;
	int i;

	gen64_init(&gen, enter_squares_without_cubes);

	for (i = 0; i < 20; i++)
		next64(&gen);
	for (i = 0; i < 9; i++)
		printf("%" PRId64 ", ", next64(&gen));
	printf("%" PRId64 "\n", next64(&gen));

	gen.free(&gen); 
	return 0;
}

C++: #include <iostream>
using namespace std;

template<class T>
class Generator
{
public:
  virtual T operator()() = 0;
};


template<class T, T P>
class PowersGenerator: Generator<T> {};


template<int P>
class PowersGenerator<int, P>: Generator<int>
{
public:
  int i;
  PowersGenerator() { i = 1; }
  virtual int operator()() 
  { 
    int o = 1; 
    for(int j = 0; j < P; ++j) o *= i; 
    ++i;
    return o; 
  }
};


template<class T, class G, class F>
class Filter: Generator<T>
{
public:
  G gen;
  F filter;
  T lastG, lastF;

  Filter() { lastG = gen(); lastF = filter(); }

  virtual T operator()() 
  {
    while(lastG >= lastF)
    {
      if(lastG == lastF)
        lastG = gen();
      lastF = filter();
    }

    T out = lastG;
    lastG = gen();
    return out;
  }
};

int main()
{
  Filter<int, PowersGenerator<int, 2>, PowersGenerator<int, 3>> gen;

  for(int i = 0; i < 20; ++i)
    gen();

  for(int i = 20; i < 30; ++i)
    cout << i << ": " << gen() << endl;
}
Task: Generator_Exponential
C: #include <inttypes.h>	
#include <stdlib.h>	
#include <stdio.h>	

#include <libco.h>	




struct gen64 {
	cothread_t giver;	
	cothread_t taker;	
	int64_t given;
	void (*free)(struct gen64 *);
	void *garbage;
};


inline void
yield64(struct gen64 *gen, int64_t value)
{
	gen->given = value;
	co_switch(gen->taker);
}


inline int64_t
next64(struct gen64 *gen)
{
	gen->taker = co_active();
	co_switch(gen->giver);
	return gen->given;
}

static void
gen64_free(struct gen64 *gen)
{
	co_delete(gen->giver);
}

struct gen64 *entry64;


inline void
gen64_init(struct gen64 *gen, void (*entry)(void))
{
	if ((gen->giver = co_create(4096, entry)) == NULL) {
		
		fputs("co_create: Cannot create cothread\n", stderr);
		exit(1);
	}
	gen->free = gen64_free;
	entry64 = gen;
}




void
powers(struct gen64 *gen, int64_t m)
{
	int64_t base, exponent, n, result;

	for (n = 0;; n++) {
		
		base = n;
		exponent = m;
		for (result = 1; exponent != 0; exponent >>= 1) {
			if (exponent & 1) result *= base;
			base *= base;
		}
		yield64(gen, result);
	}
	
}


#define ENTRY(name, code) static void name(void) { code; }
ENTRY(enter_squares, powers(entry64, 2))
ENTRY(enter_cubes, powers(entry64, 3))

struct swc {
	struct gen64 cubes;
	struct gen64 squares;
	void (*old_free)(struct gen64 *);
};

static void
swc_free(struct gen64 *gen)
{
	struct swc *f = gen->garbage;
	f->cubes.free(&f->cubes);
	f->squares.free(&f->squares);
	f->old_free(gen);
}


void
squares_without_cubes(struct gen64 *gen)
{
	struct swc f;
	int64_t c, s;

	gen64_init(&f.cubes, enter_cubes);
	c = next64(&f.cubes);

	gen64_init(&f.squares, enter_squares);
	s = next64(&f.squares);

	
	f.old_free = gen->free;
	gen->garbage = &f;
	gen->free = swc_free;

	for (;;) {
		while (c < s)
			c = next64(&f.cubes);
		if (c != s)
			yield64(gen, s);
		s = next64(&f.squares);
	}
	
}

ENTRY(enter_squares_without_cubes, squares_without_cubes(entry64))


int
main()
{
	struct gen64 gen;
	int i;

	gen64_init(&gen, enter_squares_without_cubes);

	for (i = 0; i < 20; i++)
		next64(&gen);
	for (i = 0; i < 9; i++)
		printf("%" PRId64 ", ", next64(&gen));
	printf("%" PRId64 "\n", next64(&gen));

	gen.free(&gen); 
	return 0;
}

Go: package main

import (
    "fmt"
    "math"
)


func newPowGen(e float64) func() float64 {
    var i float64
    return func() (r float64) {
        r = math.Pow(i, e)
        i++
        return
    }
}



func newMonoIncA_NotMonoIncB_Gen(af, bf func() float64) func() float64 {
    a, b := af(), bf()
    return func() (r float64) {
        for {
            if a < b {
                r = a
                a = af()
                break
            }
            if b == a {
                a = af()
            }
            b = bf()
        }
        return
    }
}

func main() {
    fGen := newMonoIncA_NotMonoIncB_Gen(newPowGen(2), newPowGen(3))
    for i := 0; i < 20; i++ {
        fGen()
    }
    for i := 0; i < 10; i++ {
        fmt.Print(fGen(), " ")
    }
    fmt.Println()
}
Task: Generator_Exponential
C: #include <inttypes.h>	
#include <stdlib.h>	
#include <stdio.h>	

#include <libco.h>	




struct gen64 {
	cothread_t giver;	
	cothread_t taker;	
	int64_t given;
	void (*free)(struct gen64 *);
	void *garbage;
};


inline void
yield64(struct gen64 *gen, int64_t value)
{
	gen->given = value;
	co_switch(gen->taker);
}


inline int64_t
next64(struct gen64 *gen)
{
	gen->taker = co_active();
	co_switch(gen->giver);
	return gen->given;
}

static void
gen64_free(struct gen64 *gen)
{
	co_delete(gen->giver);
}

struct gen64 *entry64;


inline void
gen64_init(struct gen64 *gen, void (*entry)(void))
{
	if ((gen->giver = co_create(4096, entry)) == NULL) {
		
		fputs("co_create: Cannot create cothread\n", stderr);
		exit(1);
	}
	gen->free = gen64_free;
	entry64 = gen;
}




void
powers(struct gen64 *gen, int64_t m)
{
	int64_t base, exponent, n, result;

	for (n = 0;; n++) {
		
		base = n;
		exponent = m;
		for (result = 1; exponent != 0; exponent >>= 1) {
			if (exponent & 1) result *= base;
			base *= base;
		}
		yield64(gen, result);
	}
	
}


#define ENTRY(name, code) static void name(void) { code; }
ENTRY(enter_squares, powers(entry64, 2))
ENTRY(enter_cubes, powers(entry64, 3))

struct swc {
	struct gen64 cubes;
	struct gen64 squares;
	void (*old_free)(struct gen64 *);
};

static void
swc_free(struct gen64 *gen)
{
	struct swc *f = gen->garbage;
	f->cubes.free(&f->cubes);
	f->squares.free(&f->squares);
	f->old_free(gen);
}


void
squares_without_cubes(struct gen64 *gen)
{
	struct swc f;
	int64_t c, s;

	gen64_init(&f.cubes, enter_cubes);
	c = next64(&f.cubes);

	gen64_init(&f.squares, enter_squares);
	s = next64(&f.squares);

	
	f.old_free = gen->free;
	gen->garbage = &f;
	gen->free = swc_free;

	for (;;) {
		while (c < s)
			c = next64(&f.cubes);
		if (c != s)
			yield64(gen, s);
		s = next64(&f.squares);
	}
	
}

ENTRY(enter_squares_without_cubes, squares_without_cubes(entry64))


int
main()
{
	struct gen64 gen;
	int i;

	gen64_init(&gen, enter_squares_without_cubes);

	for (i = 0; i < 20; i++)
		next64(&gen);
	for (i = 0; i < 9; i++)
		printf("%" PRId64 ", ", next64(&gen));
	printf("%" PRId64 "\n", next64(&gen));

	gen.free(&gen); 
	return 0;
}

VB: 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
Task: Generator_Exponential
C#: using System;
using System.Collections.Generic;
using System.Linq;

static class Program {
    static void Main() {
        Func<int, IEnumerable<int>> ms = m => Infinite().Select(i => (int)Math.Pow(i, m));
        var squares = ms(2);
        var cubes = ms(3);
        var filtered = squares.Where(square => cubes.First(cube => cube >= square) != square);
        var final = filtered.Skip(20).Take(10);
        foreach (var i in final) Console.WriteLine(i);
    }

    static IEnumerable<int> Infinite() {
        var i = 0;
        while (true) yield return i++;
    }
}

C++: #include <iostream>
using namespace std;

template<class T>
class Generator
{
public:
  virtual T operator()() = 0;
};


template<class T, T P>
class PowersGenerator: Generator<T> {};


template<int P>
class PowersGenerator<int, P>: Generator<int>
{
public:
  int i;
  PowersGenerator() { i = 1; }
  virtual int operator()() 
  { 
    int o = 1; 
    for(int j = 0; j < P; ++j) o *= i; 
    ++i;
    return o; 
  }
};


template<class T, class G, class F>
class Filter: Generator<T>
{
public:
  G gen;
  F filter;
  T lastG, lastF;

  Filter() { lastG = gen(); lastF = filter(); }

  virtual T operator()() 
  {
    while(lastG >= lastF)
    {
      if(lastG == lastF)
        lastG = gen();
      lastF = filter();
    }

    T out = lastG;
    lastG = gen();
    return out;
  }
};

int main()
{
  Filter<int, PowersGenerator<int, 2>, PowersGenerator<int, 3>> gen;

  for(int i = 0; i < 20; ++i)
    gen();

  for(int i = 20; i < 30; ++i)
    cout << i << ": " << gen() << endl;
}
Task: Generator_Exponential
C++: #include <iostream>
using namespace std;

template<class T>
class Generator
{
public:
  virtual T operator()() = 0;
};


template<class T, T P>
class PowersGenerator: Generator<T> {};


template<int P>
class PowersGenerator<int, P>: Generator<int>
{
public:
  int i;
  PowersGenerator() { i = 1; }
  virtual int operator()() 
  { 
    int o = 1; 
    for(int j = 0; j < P; ++j) o *= i; 
    ++i;
    return o; 
  }
};


template<class T, class G, class F>
class Filter: Generator<T>
{
public:
  G gen;
  F filter;
  T lastG, lastF;

  Filter() { lastG = gen(); lastF = filter(); }

  virtual T operator()() 
  {
    while(lastG >= lastF)
    {
      if(lastG == lastF)
        lastG = gen();
      lastF = filter();
    }

    T out = lastG;
    lastG = gen();
    return out;
  }
};

int main()
{
  Filter<int, PowersGenerator<int, 2>, PowersGenerator<int, 3>> gen;

  for(int i = 0; i < 20; ++i)
    gen();

  for(int i = 20; i < 30; ++i)
    cout << i << ": " << gen() << endl;
}

Go: package main

import (
    "fmt"
    "math"
)


func newPowGen(e float64) func() float64 {
    var i float64
    return func() (r float64) {
        r = math.Pow(i, e)
        i++
        return
    }
}



func newMonoIncA_NotMonoIncB_Gen(af, bf func() float64) func() float64 {
    a, b := af(), bf()
    return func() (r float64) {
        for {
            if a < b {
                r = a
                a = af()
                break
            }
            if b == a {
                a = af()
            }
            b = bf()
        }
        return
    }
}

func main() {
    fGen := newMonoIncA_NotMonoIncB_Gen(newPowGen(2), newPowGen(3))
    for i := 0; i < 20; i++ {
        fGen()
    }
    for i := 0; i < 10; i++ {
        fmt.Print(fGen(), " ")
    }
    fmt.Println()
}
Task: Generator_Exponential
C++: #include <iostream>
using namespace std;

template<class T>
class Generator
{
public:
  virtual T operator()() = 0;
};


template<class T, T P>
class PowersGenerator: Generator<T> {};


template<int P>
class PowersGenerator<int, P>: Generator<int>
{
public:
  int i;
  PowersGenerator() { i = 1; }
  virtual int operator()() 
  { 
    int o = 1; 
    for(int j = 0; j < P; ++j) o *= i; 
    ++i;
    return o; 
  }
};


template<class T, class G, class F>
class Filter: Generator<T>
{
public:
  G gen;
  F filter;
  T lastG, lastF;

  Filter() { lastG = gen(); lastF = filter(); }

  virtual T operator()() 
  {
    while(lastG >= lastF)
    {
      if(lastG == lastF)
        lastG = gen();
      lastF = filter();
    }

    T out = lastG;
    lastG = gen();
    return out;
  }
};

int main()
{
  Filter<int, PowersGenerator<int, 2>, PowersGenerator<int, 3>> gen;

  for(int i = 0; i < 20; ++i)
    gen();

  for(int i = 20; i < 30; ++i)
    cout << i << ": " << gen() << endl;
}

Java: import java.util.function.LongSupplier;
import static java.util.stream.LongStream.generate;

public class GeneratorExponential implements LongSupplier {
    private LongSupplier source, filter;
    private long s, f;

    public GeneratorExponential(LongSupplier source, LongSupplier filter) {
        this.source = source;
        this.filter = filter;
        f = filter.getAsLong();
    }

    @Override
    public long getAsLong() {
        s = source.getAsLong();

        while (s == f) {
            s = source.getAsLong();
            f = filter.getAsLong();
        }

        while (s > f) {
            f = filter.getAsLong();
        }

        return s;
    }

    public static void main(String[] args) {
        generate(new GeneratorExponential(new SquaresGen(), new CubesGen()))
                .skip(20).limit(10)
                .forEach(n -> System.out.printf("%d ", n));
    }
}

class SquaresGen implements LongSupplier {
    private long n;

    @Override
    public long getAsLong() {
        return n * n++;
    }
}

class CubesGen implements LongSupplier {
    private long n;

    @Override
    public long getAsLong() {
        return n * n * n++;
    }
}
Task: Generator_Exponential
C++: #include <iostream>
using namespace std;

template<class T>
class Generator
{
public:
  virtual T operator()() = 0;
};


template<class T, T P>
class PowersGenerator: Generator<T> {};


template<int P>
class PowersGenerator<int, P>: Generator<int>
{
public:
  int i;
  PowersGenerator() { i = 1; }
  virtual int operator()() 
  { 
    int o = 1; 
    for(int j = 0; j < P; ++j) o *= i; 
    ++i;
    return o; 
  }
};


template<class T, class G, class F>
class Filter: Generator<T>
{
public:
  G gen;
  F filter;
  T lastG, lastF;

  Filter() { lastG = gen(); lastF = filter(); }

  virtual T operator()() 
  {
    while(lastG >= lastF)
    {
      if(lastG == lastF)
        lastG = gen();
      lastF = filter();
    }

    T out = lastG;
    lastG = gen();
    return out;
  }
};

int main()
{
  Filter<int, PowersGenerator<int, 2>, PowersGenerator<int, 3>> gen;

  for(int i = 0; i < 20; ++i)
    gen();

  for(int i = 20; i < 30; ++i)
    cout << i << ": " << gen() << endl;
}

Python: 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)))
Task: Generator_Exponential
C++: #include <iostream>
using namespace std;

template<class T>
class Generator
{
public:
  virtual T operator()() = 0;
};


template<class T, T P>
class PowersGenerator: Generator<T> {};


template<int P>
class PowersGenerator<int, P>: Generator<int>
{
public:
  int i;
  PowersGenerator() { i = 1; }
  virtual int operator()() 
  { 
    int o = 1; 
    for(int j = 0; j < P; ++j) o *= i; 
    ++i;
    return o; 
  }
};


template<class T, class G, class F>
class Filter: Generator<T>
{
public:
  G gen;
  F filter;
  T lastG, lastF;

  Filter() { lastG = gen(); lastF = filter(); }

  virtual T operator()() 
  {
    while(lastG >= lastF)
    {
      if(lastG == lastF)
        lastG = gen();
      lastF = filter();
    }

    T out = lastG;
    lastG = gen();
    return out;
  }
};

int main()
{
  Filter<int, PowersGenerator<int, 2>, PowersGenerator<int, 3>> gen;

  for(int i = 0; i < 20; ++i)
    gen();

  for(int i = 20; i < 30; ++i)
    cout << i << ": " << gen() << endl;
}

VB: 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
Task: Generator_Exponential
C#: using System;
using System.Collections.Generic;
using System.Linq;

static class Program {
    static void Main() {
        Func<int, IEnumerable<int>> ms = m => Infinite().Select(i => (int)Math.Pow(i, m));
        var squares = ms(2);
        var cubes = ms(3);
        var filtered = squares.Where(square => cubes.First(cube => cube >= square) != square);
        var final = filtered.Skip(20).Take(10);
        foreach (var i in final) Console.WriteLine(i);
    }

    static IEnumerable<int> Infinite() {
        var i = 0;
        while (true) yield return i++;
    }
}

Go: package main

import (
    "fmt"
    "math"
)


func newPowGen(e float64) func() float64 {
    var i float64
    return func() (r float64) {
        r = math.Pow(i, e)
        i++
        return
    }
}



func newMonoIncA_NotMonoIncB_Gen(af, bf func() float64) func() float64 {
    a, b := af(), bf()
    return func() (r float64) {
        for {
            if a < b {
                r = a
                a = af()
                break
            }
            if b == a {
                a = af()
            }
            b = bf()
        }
        return
    }
}

func main() {
    fGen := newMonoIncA_NotMonoIncB_Gen(newPowGen(2), newPowGen(3))
    for i := 0; i < 20; i++ {
        fGen()
    }
    for i := 0; i < 10; i++ {
        fmt.Print(fGen(), " ")
    }
    fmt.Println()
}
Task: Generator_Exponential
C#: using System;
using System.Collections.Generic;
using System.Linq;

static class Program {
    static void Main() {
        Func<int, IEnumerable<int>> ms = m => Infinite().Select(i => (int)Math.Pow(i, m));
        var squares = ms(2);
        var cubes = ms(3);
        var filtered = squares.Where(square => cubes.First(cube => cube >= square) != square);
        var final = filtered.Skip(20).Take(10);
        foreach (var i in final) Console.WriteLine(i);
    }

    static IEnumerable<int> Infinite() {
        var i = 0;
        while (true) yield return i++;
    }
}

Java: import java.util.function.LongSupplier;
import static java.util.stream.LongStream.generate;

public class GeneratorExponential implements LongSupplier {
    private LongSupplier source, filter;
    private long s, f;

    public GeneratorExponential(LongSupplier source, LongSupplier filter) {
        this.source = source;
        this.filter = filter;
        f = filter.getAsLong();
    }

    @Override
    public long getAsLong() {
        s = source.getAsLong();

        while (s == f) {
            s = source.getAsLong();
            f = filter.getAsLong();
        }

        while (s > f) {
            f = filter.getAsLong();
        }

        return s;
    }

    public static void main(String[] args) {
        generate(new GeneratorExponential(new SquaresGen(), new CubesGen()))
                .skip(20).limit(10)
                .forEach(n -> System.out.printf("%d ", n));
    }
}

class SquaresGen implements LongSupplier {
    private long n;

    @Override
    public long getAsLong() {
        return n * n++;
    }
}

class CubesGen implements LongSupplier {
    private long n;

    @Override
    public long getAsLong() {
        return n * n * n++;
    }
}