[Question]
  [
Write a program, given an input *n*, will generate all possible n-tuples using natural numbers.
```
n=1
(1),(2),(3),(4),(5),(6)...
n=2
(1,1),(1,2),(2,1),(2,2),(1,3),(3,1),(2,3),(3,2),(3,3)...
n=6
(1,1,1,1,1,1) (1,1,1,1,2,1) (1,1,1,2,1,1)... 
```
* The output may be in any order that does not break any other rules.
* The program must be written to run forever and list all applicable tuples exactly once, in theory.
	+ In reality, your program will reach your integer type's limit and crash. This is acceptable as long the program *would* run infinitely long if only your integer type was unlimited.
	+ Each valid tuple must be listed within finite time, if only the program were allowed to run that long.
* The output may, at your option, include zeroes in addition to the natural numbers.
* You may choose your program's output format for your convenience, as long as the separation between tuples and numbers inside each tuple is clear and consistent. (For example, one tuple per line.)
* The input (n) is an integer from one to six. Required behavior is undefined for inputs outside of this range.
* Code-golf rules apply, shortest program wins.
Thanks to "Artemis Fowl" for feedback during the sandbox phase. 
  
[Answer]
# [Husk](https://github.com/barbuz/Husk), 2 bytes
```
πN
```
[Try it online!](https://tio.run/##yygtzv7//3yD3////40B "Husk – Try It Online")
## Explanation
`N` is the infinite list of natural numbers `[1,2,3,4,..`.
`π` is Cartesian power.
Result is an infinite list of lists.
Each list of the desired length occurs exactly once because `π` is cool like that.
Input and output are implicit.
[Answer]
# [Haskell](https://www.haskell.org/), 62 bytes
```
([1..]>>=).(!)
0!s=[[]|s<1]
n!s=[a:p|a<-[1..s],p<-(n-1)!(s-a)]
```
[Try it online!](https://tio.run/##FYxBDsIgEADvvGKbeIBECBy8GOgPfAESs6lFm1LcuD327WJ7m0km80aex1JahgD3JqMzJvV9UEZ2StiOQ4xpY@@SqIfglTb0@sg4nclrWbVTnWSNKrUFp7p/nh8BsCDdHkDfqa5wghXnEZy1O2a4tN@QC7646YHoDw "Haskell – Try It Online")
`n!s` generates all the `n`-tuples that sum to `s`.
Then the answer is `([1..]>>=).(!)`, i.e. `\n -> [t | s<-[1..], t<-n!s]`.
This is a function mapping an integer `n` to an infinite lazy list of tuples (lists of integers).
[Answer]
# [Haskell](https://www.haskell.org/), 50 bytes
```
f n=[l|k<-[0..],l<-mapM([0..k]<$f)[0..n],sum l==k]
```
[Try it online!](https://tio.run/##FccxDoAgDADAr3Rw0AQMxhWe4AsMQ2NESQshoptvt@p2t2OllVkkQHYz32T1bPreK7Y6YZnaf@RtE7pf2at6JWDnyEvCmMFBOWI@oYETaYXBmI8BRnmWwLhV0UspLw "Haskell – Try It Online")
Lists `n`-tuples sorted by sum. `mapM` does the heavy lifting to generate all `n`-tuples of numbers from 0 to k. The `<$f` trick is [explained here](https://codegolf.stackexchange.com/a/181531/20260).
# [Haskell](https://www.haskell.org/), 51 bytes
```
f 1=pure<$>[0..]
f n=[a-k:k:t|a:t<-f$n-1,k<-[0..a]]
```
[Try it online!](https://tio.run/##FcqxDoMgEADQ3a@4gdEzkG4E@iOG4WI4a44Sorj57Z7t9ob3oUNyKaoMLrZzz8G8ZztNaWCocSYUL75f5HtANhXdKAH/gVLSL20VIrR9qx0MdJIMztofGV56L1xoPRSX1h4 "Haskell – Try It Online")
Recursively stretches all `n-1`-tuples into all `n`-tuples by splitting the first number `a` of each `n-1`-tuple into two numbers `a-k,k` that sum to it, in every possible way.
[Answer]
# Pyth - 9 bytes
*Thanks to @FryAmTheEggman for the golf*
Loops through all x, and takes [1..x]^n. This makes duplicates, so only keeps ones that are new to that x, aka contain x in them. The formatting is a little weird, but it can be made standard with one more byte, `.V1j}#b^Sb`
```
.V1}#b^Sb
```
[Try it online](https://tio.run/##K6gsyfj/Xy/MMKtWOSkuOOn/fzMA).
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog) (v2), 9 bytes
```
~l.ℕᵐ+≜∧≜
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/qG3Do6bGh9sWHNr5qHEDBD3c1fm/LkfvUcvUh1snaD/qnPOoYzmQ/P/fGAA "Brachylog – Try It Online")
This is an infinite generator that generates all possible tuples. The TIO link has a header that uses the generator to generate 1000 elements and prints them (but the generator could continue indefinitely if I asked for that instead; Brachylog's integers are unbounded).
It feels like there should be a terser way, but there are a lot of constraints and this is the tersest I can fit them into a single program.
## Explanation
```
~l.ℕᵐ+≜∧≜
  .        Generate
        ≜  all explicit
~l         lists whose length is {the input}
    ᵐ      for which every element
   ℕ       is non-negative
     +     and whose sum
      ≜    is used to order the lists (closest to zero first)
       ∧   [remove unwanted implicit constraint]
```
Incidentally, it strikes me as interesting just how different my explanations of the two `≜` are, despite them doing the exact same thing from Brachylog's point of view. The first `≜` is the first nondeterministic predicate in the program, so it sets the order of results; in this case, it calculates all possible explicit values for the sum of the list in the order 0, 1, 2, 3…, and is being used to ensure that the lists are output in order of their sum (this ensures that each possible list appears after a finite amount of output). The second `≜` is used to calculate all the explicit possibilities for the list (rather than outputting a formula specifying how the elements of the list relate to each other).
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 148 bytes
```
n=>{var a=new int[n];int j=0;void g(int k){if(k<n)for(int i=0;i++<j;g(k+1))a[k]=i;else if(a.Sum()==j)WriteLine(string.Join(' ',a));}for(;;j++)g(0);}
```
[Try it online!](https://tio.run/##HYyxDoIwFEV3v6IbfakSjOOjJK7GzcGBMDRYmtfqIymIA/Hba3G6OScnt58O/UTp3M80ck08N4NOrJt1MVEYzfYjsmy5wzzC6wqXkR7CyQ0DrDTIUDMMY/wbygEpVXt0MqgjgGlDpwntc7Iit6a8vV8StPZwjzTbK7GV0xyJXXkZiWUhir0BwO/2iOiVAierzAl3gzwBph8 "C# (Visual C# Interactive Compiler) – Try It Online")
-3 bytes thanks to @ASCIIOnly!
```
// n: size of tuples to generate
n=>{
  // a: current tuple workspace
  var a=new int[n];
  // j: target sum value
  int j=0;
  // recursive function that works on slot k
  void g(int k){
    // tuple is not fully generated,
    if(k<n)
      // try all values from (0,j]
      for(int i=0;i++<j;
        // recursive call - generates all
        // values from (0,j] in the next slot
        g(k+1)
      )
        // update the kth slot
        a[k]=i;
    // tuple is fully generated, however
    // we should only display if the sum
    // is equal to the target sum. tuples
    // are generated many times, this
    // let's us enforce that they are only
    // displayed once.
    else if(a.Sum()==j)
      WriteLine(string.Join(' ',a));
  }
  // increment the high value forever
  // while continually starting the
  // recursive function at slot 0
  for(;;j++)
    g(0);
}
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~62~~ 52 bytes
```
Do[Print/@(1+1~Table~#~FrobeniusSolve~--n),{n,∞}]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73yU/OqAoM69E30HDUNuwLiQxKSe1TrnOrSg/KTUvs7Q4OD@nLLVOVzdPU6c6T@dRx7zaWLX/aQ5m/wE "Wolfram Language (Mathematica) – Try It Online")
---
-2 bytes with inconsistent separation: [Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73yU/OqAoM68k2lDbsC4kMSkntU65zq0oPyk1L7O0ODg/pyy1Tlc3L1anOk/nUce82li1/2kOZv8B "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 (9?) [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
9 if we may output using non-consistent separation (which I have enquired about) -- removal of the `€`.
```
‘ɼṗ³ċƇ®Ṅ€ß
```
**[Try it online!](https://tio.run/##ASMA3P9qZWxsef//4oCYybzhuZfCs8SLxofCruG5hOKCrMOf////Mw "Jelly – Try It Online")**
### How?
```
‘ɼṗ³ċƇ®Ṅ€ß - Main Link: some argument, x (initially equal to n, but unused)
 ɼ         - recall v from the register (initially 0), then set register to, and yield, f(v)
‘          -   f = increment
           - (i.e. v=v+1)
   ³       - program's third command line argument (1st program argument) = n
  ṗ        - (implicit range of [1..v]) Cartesian power (n)
           - (i.e. all tuples of length n with items in [1..v])
     Ƈ     - filter keep those for which:
    ċ      -   count
      ®    -   recall from register
           - (i.e. keep only those containing v)
       Ṅ€  - print €ach
         ß - call this Link with the same arity
           - (i.e. call Main(theFilteredList), again the argument is not actually used)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~15~~ 11 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
[¼¾LIãvy¾å—
```
-4 bytes by creating a port of [*@Maltysen*'s Pyth answer](https://codegolf.stackexchange.com/a/183240/52210).
[Try it online.](https://tio.run/##AR0A4v9vc2FiaWX//1vCvMK@TEnDo3Z5wr7DpeKAlP//Mw)
**Explanation:**
```
[             # Start an infinite loop:
 ¼            #  Increase the counter_variable by 1 (0 by default)
  ¾L          #  Create a list in the range [1, counter_variable]
    Iã        #  Take the cartesian power of this list with the input
      v       #  Loop over each list `y` in this list of lists:
       y¾å    #   If list `y` contains the counter_variable:
          —   #    Print list `y` with trailing newline
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 16 bytes
```
`@:GZ^t!Xs@=Y)DT
```
Tuples are ordered by increasing sum, and within a given sum they are ordered lexicographically. 
[**Try it online!**](https://tio.run/##y00syfn/P8HByj0qrkQxotjBNlLTJeT/f1MA)
[Answer]
# [Python 2](https://docs.python.org/2/), ~~126~~ ~~112~~ ~~106~~ ~~101~~ ~~100~~ 83 bytes
```
n=input()
i=1
while 1:
 b=map(len,bin(i)[3:].split('0'));i+=1
 if len(b)==n:print b
```
[Try it online!](https://tio.run/##DcpNCoNADAbQ/ZwiOxMqxZ/dlJxEXDig@ME0DXVEevqpb/38V/aPDbWawvwsLAHah2tHXqmPgZK@F@e8WptgDJnGOD8PzyjcdI3IC4/7Eza6DydRtehfWKFU6/gH "Python 2 – Try It Online")
5 bytes thx to [mypetlion](https://codegolf.stackexchange.com/users/65255/mypetlion); 1 byte from the eagle eye of [ArBo](https://codegolf.stackexchange.com/users/82577/arbo); 17 bytes from [xnor](https://codegolf.stackexchange.com/users/20260/xnor)!
Construct the ordered partitions of `m` into `n` bins, for `m = 0,1,2,3,...` by selecting for binary numbers with `n-1` `0`s and `m` `1`s.
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), ~~608 570~~ 567 bytes
```
using C=System.Console;using L=System.Collections.Generic.List<int[]>;class A{static void Main(){L x=new L(),y=new L(),z=new L();int i=int.Parse(C.ReadLine()),j=0,k,l,m;x.Add(new int[i]);while(i>0){j++;for(m=0;m++<i;){foreach(var a in y)x.Add(a);y=new L();foreach(var a in x){for(k=0;k<i;){int[] t=new int[i];System.Array.Copy(a,t,i);t[k++]=j;var b=true;z.AddRange(x);z.AddRange(y);foreach(var c in z){for(l=0;l<i;l++)if(c[l]!=t[l])break;if(l==i)b=false;}if(b)y.Add(t);}}}}for(k=0;k<x.Count;k++){C.Write("[ ");for(l=0;l<i;l++)C.Write(x[k][l]+" ");C.WriteLine("]");}}}
```
[Try it online!](https://tio.run/##ZZHBbtswDIZfRfNJhDwjwI6sCgQ57OIBQ3fYwfBBUZSWsSIPktLaMfrsGe20zYrpIFA/xf8jJZu@2j66y@WUKDyKjf41puyO1aYPqfcOr3J9k713NhNnq@8uuEi2qinlOwq5ae/RepOSWE8pm0xWPPe0Ez8MBQlTLQYd3IuoJZTjR3R@j5AdBGneq58mJic31YMzu5qCkwDlQa/KrvTlEYdqvdvJuWpmUgv48kTeSbpfwXRQCvd9lEe9wqNSd4Qw8dkZ@ySfTRSGi8QIVw8D@NEI/ndrWCplx07d4rOMKLK@ofHtVdYxmpHf5s8oTZlLAsxNp1SrDzjbbXWOJ4fnGfpgwqOTA/x7Gj/T7Uw/X@me6Z7pXimgvbSNb7/ozDtsuaBD1rzWBFu9Nz45fGVhC@MyXgZ85XUbYuAWTyEjtwbTpvodKTtZNKJY@J9Y79mh6VqmqWK@9CYuX1K0xWJ/uXz7Cw "C# (.NET Core) – Try It Online")
my god what have I done
(so many loops, that's what I've done)
It should work, though!
If you move the print loop back one bracket, it will show you the list as it's built, every time it loops. (I recommend adding a newline or something to distinguish each loop if you do.)
Honestly, a *lot* of my time was spent fighting with the language...no pretty-printing arrays, assorted behaviors of ==...
Hopefully this version is easier to read.
```
using C=System.Console;
using L=System.Collections.Generic.List<int[]>;
class A{
    static void Main(){
        L x=new L(),y=new L(),z=new L();
        int i=int.Parse(C.ReadLine()),j=0,k,l,m;
        x.Add(new int[i]);
        while(i>0){
            j++;
            for(m=0;m++<i;){
                foreach(var a in y) x.Add(a);
                y=new L();
                foreach(var a in x){
                    for(k=0;k<i;){
                        int[] t=new int[i];
                        System.Array.Copy(a,t,i);
                        t[k++]=j;
                        var b=true;
                        z.AddRange(x);
                        z.AddRange(y);
                        foreach(var c in z){
                            for(l=0;l<i;l++) if(c[l]!=t[l])break;
                            if(l==i)b=false;
                        }
                        if(b)y.Add(t);
                    }
                }
            }
        }
        for(k=0;k<x.Count;k++){
            C.Write("[ ");
            for(l=0;l<i;l++)C.Write(x[k][l]+" ");
            C.WriteLine("]");
        }
    }
}
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 50 bytes
```
{grep $_,{S/.//.split(0)>>.chars}($++.base(2))xx*}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwvzq9KLVAQSVepzpYX09fX6@4ICezRMNA085OLzkjsai4VkNFW1svKbE4VcNIU7OiQqv2f25igYKWXnFipU6ahrFmdJyhgUGs9X9jAA "Perl 6 – Try It Online")
Anonymous code block that returns a lazy infinite list. This uses the same strategy as [Chas Brown's answer](https://codegolf.stackexchange.com/a/183251/76162).
### Explanation:
```
{grep $_,{S/.//.split(0)>>.chars}($++.base(2))xx*}
{                                                } # Anonymous code block
                                              xx*  # Repeat indefinitely
                                 ($++        )     # From the current index
                                     .base(2)      # Get the binary form
         {S/.//                 }   # Remove the first digit
               .split(0)            # And split by zeroes
                        >>.chars    # And get the length of each section
 grep   ,   # From this infinite list, filter:
      $_      # The groups with length the same as the input
```
[Answer]
# [VDM-SL](https://raw.githubusercontent.com/overturetool/documentation/master/documentation/VDM10LangMan/VDM10_lang_man.pdf), 51 bytes
```
g(i)==if i=0then{}else{[x]^y|x:nat,y in set g(i-1)}
```
Recursive set comprehension with sequence concatenation..
Not on TIO, you could run in a program (if you turn on limits for nat type or it wont terminate):
```
functions 
g:nat->set of ?
g(i)==if i=0then{}else{[x]^y|x:nat,y in set g(i-1)}
```
Includes the optional 0s in answer otherwise it would be 52 bytes binding on nat1
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 131 bytes
```
While[0<1,If[a~FreeQ~#,Print@#]&/@(b=Table[Select[Range@t~Tuples~{s},Tr@#==k&],{k,t,t(s=#)}]~Flatten~1);a={a}~Join~b;t++]&
t=1
a={}
```
[Try it online!](https://tio.run/##Dcq9CoMwEADg3dcIiGKgdehkA05CO/VH6BAynHLVYEyLXifJvXrq@vHNQCPOQLaHOKj4Gq1DfTyX8vLWwM2CeGchb4v1VAuTHuqsUy10e3qiw570A/yANXH7@zpceVuDbJdaKDWlRm6TJEnZqkQeDDcOiNBzmVegNgh8/VjPXUVFYdKEVJnsHOKgTybGPw "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# perl -M5.010 122 bytes
```
$n=shift;
$s.="for\$x$\_(1..\$m){"for 1..$n;
$t.="\$x$\_ "for 1..$n;
$u.='}'x$n;
eval"{\$m++;$s\$\_=qq' $t';/ \$m /&&say$u;redo}"
```
Added some newlines for readabilities sake (not counted in the byte count)
[Answer]
# [Python 2](https://docs.python.org/2/), 120 bytes
```
from random import*
m=n=input()
a=()
while 1:
 m+=len(a)==m**n;t=[randint(1,m)for _ in[1]*n]
 if(t in a)<1:a+=t,;print t
```
[Try it online!](https://tio.run/##FYtBCsMwDATvfoWOtpOLc0yql4RQDI2JIJKNUCl9vetedhiYbV@7qiy9F60MmuU1QNyqWnSMgiTtbT64jGM@F90npNUBT3if4nNA5BhlM9z/ZxLzaeZQqsITSPZ0RDkcUPE2FHJ4pDVPaPPWdMRgvS8/ "Python 2 – Try It Online")
A bit longer than most other answers, but I liked the idea behind it.
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 6 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
£ƒ$↔┬ï
```
[Run and debug it](https://staxlang.xyz/#p=9c9f241dc28b&i=4)
For input `n` the procedure is roughly 
```
for i in [0..infinity]:
    get all the distinct n length arrays of positive integers that sum to i
    for each
        join with spaces
        implicitly output
```
[Answer]
# [JavaScript (V8)](https://v8.dev/), 98 bytes
```
n=>{for(a=[],b=[j=1];;b.push(++j))(g=k=>k<n?b.map(i=>(a[k]=i)|g(k+1)):a.includes(j)&&print(a))(0)}
```
[Try it online!](https://tio.run/##DctBDsIgEADA3zS7QYmNF2NdfAjhsFSpgEUCbS/q29G5T@CN61h8XvbbqTlqidTbvQowabOzpAP1ZhiszGt9gBABESaKpOIlXa2cOYMnBayjIY@fCaLoEc8sfRqf6@1eIWDX5eLTAvy/B/w2B0dsPw "JavaScript (V8) – Try It Online")
Hooray! Finally got it under 100 :) Basically a port of [my C# answer](https://codegolf.stackexchange.com/a/183417/8340).
```
// n: length of tuples to generate
n=>{
  // a: workspace for current tuple
  // b: range of numbers that grows
  //     - iteration 1: [1]
  //     - iteration 2: [1,2]
  //     - iteration 3: [1,2,3]
  // j: largest number in b
  for(a=[],b=[j=1];;b.push(++j))
    // g: recursive function to build tuples
    // k: index of slot for current recursive call
    (g=k=>
       // current slot less than the tuple size? 
       k<n?
         // tuple generation not complete
         // try all values in current slot and
         // recurse to the next slot
         b.map(i=>(a[k]=i)|g(k+1)):
         // tuple generation complete
         // print tuple if it contains the
         // current high value
         a.includes(j)&&print(a)
    // start recursive function at slot 0
    )(0)
}
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~96~~ 90 bytes
```
n=>{for(i=0n;z=[];z.length-n||console.log(z))for(j=++i,w=0;j;j/=2n)w=j%2n?+!z.push(w):w+1}
```
[Try it online!](https://tio.run/##FcpBCsIwEADAt3gQssTGWm@G1YeIh1KTNkvYLU01EOvbI855qH/3aVjCvDYsT1c9Vsbrx8uiArZsC94ftpjoeFynhrdtEE4SnYkyqgLwj4Rah0PG1pKlI3YMGWnf8U3viplfaVIZLlmfvtWrM9Qf "JavaScript (Node.js) – Try It Online")
V8 on TIO don't support BigInt
]