text:
Stewie's sequence: + * - / + * - /
Let's use the four basic operations, addition +, multiplication *, subtraction - and division / (float, not integer).
Stewie's sequence is defined as follows:
x = [x(1), x(2)]    // Two initial numbers (one indexed)
x(3) = x(1) + x(2)
x(4) = x(2) * x(3)
x(5) = x(3) - x(4)
x(6) = x(4) / x(5)
x(7) = x(5) + x(6)
... and so on.

Challenge:
Take two non-negative integers (x(1), x(2)), and one positive integer N as input.
x(1) and x(2) will be the two first numbers of your sequence, and N will be the length of the sequence you must output. (You can choose to have the list 0-based, in which case N will be one less than the length).

You can not assume that x(2) >= x(1).
N will always be >2 if 1-based, (>1 if 0-based).
You do not have to handle division by zero errors.

Note the 2nd test case. You will not get 0, 1, and N=6 as input, since that will result in division by zero, but you must support 0, 1 and N=5.

Assume only valid input will be given.
The input and output can be on any convenient format, but you must support at least 3 digits after the decimal points if the output is non-integer.

Test cases:
1 3
8
1, 3, 4, 12, -8, -1.5, -9.5, 14.25

0 1
5
0, 1, 1, 1, 0     // N=6 would give division by zero error. You don't need to handle that case.

1 0
9
1, 0, 1, 0, 1, 0, 1, 0, 1

6 3
25
6, 3, 9, 27, -18, -1.5, -19.5, 29.25, -48.75, -0.6, -49.35, 29.61, -78.96, -0.375, -79.335, 29.7506, -109.086, -0.272727, -109.358, 29.825, -139.183, -0.214286, -139.398, 29.8709, -169.269

Can a function take x(1) and x(2) as a list? Or seperate arguments?

Whatever is convenient for you :)

Can N be 0-based? So take as inputs 1 less than the N shown in your examples. I guess taking N-2 is too much to ask for... :-P

When you write output can be on any convenient format, does that include a list with the final element in the beginning and the start-elements at the end (a reversed list)?

@LuisMendo N can be zero-based. And you're right about that second part :)

@Emigna, no I think that's a bit of a stretch... The numbers should be in the correct order

I'm working on an x86 assembly-language function (smallest machine-code) answer.  Since I can't just "return" a list, the caller has to pass a buffer as well as a length.  Can I take x1 and x2 as floats already stored in the buffer?  (i.e. a function that continues a sequence for N more values).  Otherwise I'll just take them as floats or integers on the stack or in registers, depending on whether I decide to go for 64-bit or 32-bit code, and System V calling convention or custom.

MATL, 19 18 17 bytes
q:"y'+*-/'@)hyhUV

Input is in the format: N (0-based), x(1), x(2) (as strings); all separated by newlines.
Try it online! Or verify all test cases (slightly modified code; output sequences separated by a blank line).
Explanation
MATL doesn't have a proper eval function, but U (str2num) can evaluate numeric expressions with infix operators.
Each new term is computed and pushed onto the stack, keeping the previous terms. The entire stack is printed at the end.
q          % Implicitly input N (0-based). Subtract 1
:"         % Repeat that many times
  y        %   Duplicate x(n-1), where n is the number of already computed terms
           %   In the first iteration, which corresponds to n=2, this implicitly
           %   inputs x(1) and x(2) as strings (and then duplicates x(1))
  '+*-/'   %   Push this string
  @)       %   Push iteration number and apply as modular index into the string.
           %   So this gives '+' in the first iteration, '*' in the second etc
  h        %   Concatenate horizontally. This gives a string of the form
           %   '*x(n-1)+', where '+' is the appropriate operator
  &y       %   Duplicate x(n)
  hh       %   Concatenate horizontally. This gives a string of the form
           %   'x(n-1)+x(n)'
  U        %   Convert to number. This evaluates the string
  V        %   Convert back to string. This is the new term, x(n+1)
           % Implicitly end loop and display stack

Haskell, 69 68 64 bytes
x#n=take n$x++zipWith3 id(cycle[(+),(*),(-),(/)])(x#n)(tail$x#n)

x1 and x2 are taken as a list. Usage example: [1,3] # 8 -> [1.0,3.0,4.0,12.0,-8.0,-1.5,-9.5,14.25].
Laziness makes it possible to define an infinite recursive list where we take the first n elements.
Haskell, 66 bytes
(h%g)y x=x:g(h x y)y
a=(+)%b
b=(*)%c
c=(-)%d
d=(/)%a
(.a).(.).take

Different approach, slightly longer. Argument order is N, x2, x1. Usage example: ( (.a).(.).take ) 8 3 1 -> [1.0,3.0,4.0,12.0,-8.0,-1.5,-9.5,14.25].
Defines 4 functions a, b, c and d which take two arguments y, x  and make a list by putting x in front of a call to the next function with y as the second argument and x op y as the first. For example a is: a y x = x : (b (x+y) y), b does multiplication: b y x = x : (c (x*y) y), etc.
Edit: @Michael Klein saved a byte in the 1st variant (#). Luckily I also found one byte for the second variant, so both have the same length again.
Edit II: @Zgarb found 2 bytes in the second version to save, and I 4 in the first, so they are no longer of the same length.

Accept the arguments as a list (allowed) for a byte

I always get confused if (.) is composed with other functions :p

g x=(`take`f)where doesn't save a byte :-/

Save 2 bytes in the alternative approach: (h%g)y x=x:g(h x y)y

@Zgarb: oh, that's nice. Thanks! BTW, when editing in your suggestions I found 4 bytes to save along the way in the first version.

ES6 (Javascript), 79, 67, 65 bytes
UPDATE

minus 2 bytes, by starting with i=2, as suggested by @ETHProductions
Saved 3 bytes, thanks to excellent advice from @Neil !

Golfed
S=(n,a,i=2)=>i<n?S(n,a,a.push(eval(a[i-2]+"-/+*"[i%4]+a[i-1]))):a

Test
S=(n,a,i=2)=>i<n?S(n,a,a.push(eval(a[i-2]+"-/+*"[i%4]+a[i-1]))):a

>S(8,[1,3])
Array [ 1, 3, 4, 12, -8, -1.5, -9.5, 14.25 ]

>S(5,[0,1])
Array [ 0, 1, 1, 1, 0 ]

>S(9,[1,0])
Array [ 1, 0, 1, 0, 1, 0, 1, 0, 1 ]

>S(25,[6,3])
Array [ 6, 3, 9, 27, -18, -1.5, -19.5, 29.25, -48.75, -0.6, ...]

@ETHproduction Yep, but I would have to pay them back by changing a[i] => a[i-2]

Ah, missed that.

Can you not use ++i to avoid having to add 1 to i twice?

Or, alternatively, writing ?S(n,a,i+1,a.push(...)):a might save you some bytes.

Or maybe you could use the fact that a.push returns the new length, S=(n,a,i=2)=>i<n?S(n,a,a.push(...)):a

@Neil, I've made use of a push return value, and a prefix increment for it, and that saved me the whole 3 bytes ! Thank you !

I still think you can save more bytes by starting at i=2 though.

With Neil's suggestion, I think you can do S=(n,a,i=2)=>i<n?S(n,a,a.push(eval(a[i-2]+"+*-/"[i%4]+a[i-1]))):a to save 2 bytes.

@ETHProductions, works now ! Minus 2 bytes ! Thank you ! Note that I also had to remap operators from  "+-/" => "-/+" (as i%4 yield them in a different order now).

Python 3, 90 80 74 bytes
xnor's probably going to come and destroy this solution...
def F(s,n,i=2):
 while i<n:s+=eval('%s'*3%(s[-2],'-/+*'[i%4],s[-1])),;i+=1

The function modifies the list passed to it. Use like this:
s = [1,3]
F(s,8)

Try on repl.it!
-6 bytes thanks to Copper

Since you only use O once, you can save a few bytes by doing '-/+*'[i%4] and removing the declaration of O. Also, you might be able to get around the repeated calls to str by doing something like eval('%s'*3%(s[-2],'-/+*'[i%4],s[-1])).

Oh yeah, and s+=[...] can be replaced by s+=..., (note the trailing comma).

xnor is not the only one that can destroy your solution. There is another person too: Dennis (the mod).

You're guaranteed to get i as input, so you don't need the default value for it (i=2 can be just i). Two bytes off.

@ArtOfCode no, argument 1 is the list and argument 2 is the number of terms to calculate up to. i is just a counter I am using. Read the "usage" section at the bottom...

If it was allowed to return the nth item in the sequence instead, this is 1 byte shorter with recursion: f=lambda x,n:n<2and x[n-1]or eval('%s'*3%(f(x,n-2),'*-/+'[n%4],f(x,n-1)))

Never mind. It'd have to be adjusted for x values of 0 to work. Wishful thinking... so it'd have to use ...if...else, making it the same length.

Perl 6,  75 71  61 bytes
->\a,\b,\c{$_=[|(&[+],&[*],&[-],&[/])xx*];(a,b,{.shift.($^a,$^b)}...*)[^c]}

Test it
{$_=[|(&[+],&[*],&[-],&[/])xx*];($^a,$^b,{.shift.($^a,$^b)}...*)[^$^c]}

Test it
{($^a,$^b,{(&[+],&[*],&[-],&[/])[$++%4]($^a,$^b)}...*)[^$^c]}

Test it
Expanded:
{ # bare block lambda with placeholder parameters ｢$a｣ ｢$b｣ ｢$c｣

  # generate sequence
  (
    # initialize sequence
    $^a, # declare and use first argument
    $^b, # second argument

    {  # bare block lambda with two placeholder parameters ｢$a｣ ｢$b｣

      (

        &[+], &[*], &[-], &[/] # the four operators

      )[             # index into the list of operators

         $++        # increment (++) an anonymous state variable ($)
         % 4        # modulo 4

      ]( $^a, $^b ) # and use it on the previous two values in sequence

    }

    ...  # repeat that until

    *    # indefinitely

  )[     # take only

    ^    # upto and excluding:     ( Range object )
    $^c  # third argument

  ]
}

x86-64 machine code, 34 bytes
Calling convention = x86-64 System V x32 ABI (register args with 32-bit pointers in long mode).
The function signature is void stewie_x87_1reg(float *seq_buf, unsigned Nterms);.  The function receives the x0 and x1 seed values in the first two elements of the array, and extends the sequence out to at least N more elements.  The buffer must be padded out to 2 + N-rounded-up-to-next-multiple-of-4.  (i.e. 2 + ((N+3)&~3), or just N+5).
Requiring padded buffers is normal in assembly for high-performance or SIMD-vectorized functions, and this unrolled loop is similar, so I don't think it's bending the rules too far.  The caller can easily (and should) ignore all the padding elements.
Passing x0 and x1 as a function arg not already in the buffer would cost us only 3 bytes (for a movlps [rdi], xmm0 or movups [rdi], xmm0), although this would be a non-standard calling convention since System V passes struct{ float x,y; }; in two separate XMM registers.
This is objdump -drw -Mintel output with a bit of formatting to add comments
0000000000000100 <stewie_x87_1reg>:
       ;; load inside the loop to match FSTP at the end of every iteration
       ;; x[i-1] is always in ST0
       ;; x[i-2] is re-loaded from memory
 100:   d9 47 04                fld    DWORD PTR [rdi+0x4]
 103:   d8 07                   fadd   DWORD PTR [rdi]
 105:   d9 57 08                fst    DWORD PTR [rdi+0x8]
 108:   83 c7 10                add    edi,0x10            ; 32-bit pointers save a REX prefix here

 10b:   d8 4f f4                fmul   DWORD PTR [rdi-0xc]
 10e:   d9 57 fc                fst    DWORD PTR [rdi-0x4]

 111:   d8 6f f8                fsubr  DWORD PTR [rdi-0x8]
 114:   d9 17                   fst    DWORD PTR [rdi]

 116:   d8 7f fc                fdivr  DWORD PTR [rdi-0x4]
 119:   d9 5f 04                fstp   DWORD PTR [rdi+0x4]

 11c:   83 ee 04                sub    esi,0x4
 11f:   7f df                   jg     100 <stewie_x87_1reg>
 121:   c3                      ret

0000000000000122 <stewie_x87_1reg.end>:
## 0x22 = 34 bytes

This C reference implementation compiles (with gcc -Os) to somewhat similar code.  gcc picks the same strategy I did, of keeping just one previous value in a register.
void stewie_ref(float *seq, unsigned Nterms)
{
    for(unsigned i = 2 ; i<Nterms ; ) {
        seq[i] = seq[i-2] + seq[i-1];       i++;
        seq[i] = seq[i-2] * seq[i-1];       i++;
        seq[i] = seq[i-2] - seq[i-1];       i++;
        seq[i] = seq[i-2] / seq[i-1];       i++;
    }
}

I did experiment with other ways, including a two-register x87 version that has code like:
; part of loop body from untested 2-register version.  faster but slightly larger :/
; x87 FPU register stack    ;       x1, x2   (1-based notation)
fadd    st0, st1            ; x87 = x3, x2
fst     dword [rdi+8 - 16]  ; x87 = x3, x2

fmul    st1, st0            ; x87 = x3, x4
fld     st1                 ; x87 = x4, x3, x4
fstp    dword [rdi+12 - 16] ; x87 = x3, x4
; and similar for the fsubr and fdivr, needing one fld st1

You'd do it this way if you were going for speed (and SSE wasn't available)
Putting the loads from memory inside the loop instead of once on entry might have helped, since we could just store the sub and div results out of order, but still it needs two FLD instructions to set up the stack on entry.
I also tried using SSE/AVX scalar math (starting with values in xmm0 and xmm1), but the larger instruction size is killer.  Using addps (since that's 1B shorter than addss) helps a tiny bit.  I used AVX VEX-prefixes for non-commutative instructions, since VSUBSS is only one byte longer than SUBPS (and the same length as SUBSS).
; untested.  Bigger than x87 version, and can spuriously raise FP exceptions from garbage in high elements
addps   xmm0, xmm1      ; x3
movups  [rdi+8 - 16], xmm0
mulps   xmm1, xmm0      ; xmm1 = x4,  xmm0 = x3
movups  [rdi+12 - 16], xmm1
vsubss  xmm0, xmm1, xmm0      ; not commutative.  Could use a value from memory
movups  [rdi+16 - 16], xmm0
vdivss  xmm1, xmm0, xmm1      ; not commutative
movups  [rdi+20 - 16], xmm1

Tested with this test-harness:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int main(int argc, char**argv)
{
    unsigned seqlen = 100;
    if (argc>1)
        seqlen = atoi(argv[1]);
    float first = 1.0f, second = 2.1f;
    if (argc>2)
        first = atof(argv[2]);
    if (argc>3)
        second = atof(argv[3]);

    float *seqbuf = malloc(seqlen+8);  // not on the stack, needs to be in the low32
    seqbuf[0] = first;
    seqbuf[1] = second;

    for(unsigned i=seqlen ; i<seqlen+8; ++i)
        seqbuf[i] = NAN;

    stewie_x87_1reg(seqbuf, seqlen);
//  stewie_ref(seqbuf, seqlen);
    for (unsigned i=0 ; i< (2 + ((seqlen+3)&~3) + 4) ; i++) {
        printf("%4d: %g\n", i, seqbuf[i]);
    }

    return 0;
}

Compile with nasm -felfx32 -Worphan-labels -gdwarf2 golf-stewie-sequence.asm &&
gcc -mx32 -o stewie -Og -g golf-stewie-sequence.c golf-stewie-sequence.o
Run the first test-case with ./stewie 8 1 3
If you don't have x32 libraries installed, use nasm -felf64 and leave gcc using the default -m64.  I used malloc instead of float seqbuf[seqlen+8] (on the stack) to get a low address without having to actually build as x32.

Fun fact: YASM has a bug: it uses a rel32 jcc for the loop branch, when the branch target has the same address as a global symbol.
global stewie_x87_1reg
stewie_x87_1reg:
   ;; ended up moving all prologue code into the loop, so there's nothing here
.loop:

...
sub    esi, 4
jg     .loop

assembles to ... 11f:   0f 8f db ff ff ff       jg     100 <stewie_x87_1reg>

Very nice! You beat me to a similar approach by over three years! The problem seemed to lend itself nicely to x87 stack-based operations.

@640KB: yeah, the r forms of non-commutative operations make the stack nature of x87 bearable.  IDK about "nicely"; making it small introduced a bunch of store/reloads instead of just reading both previous sequence values from registers like we can with the AVX version.

Fair enough, "nicely" is probably putting it nicely. I didn't get very far since I saw your answer before I even started. If I'm reading it right it looks like this will always run through the +,*,-,/ pattern before stopping.  Will it handle the N=5 / division by 0 test case?

@640KB: fdiv doesn't trap on division by zero with the default FP environment, merely produce a NaN.   It's been 3 years since I looked at this, but presumably that was fine.  (By default after finit, FP exceptions are masked.  Mainstream OSes / C implementations use that same x87 environment by default).

Of course! If an exception falls in the woods, does anyone hear it? :)

@640KB: yes, actually, it sets a sticky flag in the x87 status word register :P  (Or for SSE/AVX, in MXCSR) See also How to force GCC to assume that a floating-point expression is non-negative? for a summary of how C exposes this via fenv.h and fetestexcept() / feclearexcept

Mathematica, 68 bytes
(±1=#;±2=#2;±n_:=1##[#-#2,#/#2,+##][[n~Mod~4]]&[±(n-2),±(n-1)];±#3)&

Barely snuck into 3rd place! Unnamed function of three arguments, which uses a helper unary operator ± such that ±n is exactly the nth element x(n) of the Stewie sequence. The first two arguments are x(1) and x(2), and the third argument is the N indicating which x(N) we output.
Direct implementation, using a mod-4 calculation to choose which binary function to apply to the previous two terms. Picking the correct binary function, which is what 1##[#-#2,#/#2,+##] helps with, uses a few of these fun Mathematica golfing tricks.

05AB1E, 21 19 18 bytes
Input is taken in the order N(0-based), x(2), x(1).
Saved 1 byte thanks to carusocomputing.
GUDXsX"/+*-"Nè.V})

Try it online!
Explanation
 G                   # for N in [0 ... n-1] do:
  U                  # save top element of stack in X
   D                 # duplicate top of stack
    X                # push X
     s               # swap top 2 elements on stack
      X              # push X
       "/+*-"Nè      # index into the string with the current iteration number
               .V    # evaluate
                 }   # end loop
                  )  # wrap stack in list

We iteratively build the stack with the latest element in the sequence on top, while keeping all previous elements in order.
Then we wrap the stack in a list at the end to display all values at once.

I couldn't figure it out, but using XY and UV may save you bytes.

@carusocomputing: Nice catch! Saved the byte I lost from the register not working on implicit input using UX :)

Haskell, 60 bytes
g(o:z)a b=a:g z b(o a b)
p=(+):(*):(-):(/):p
(.g p).(.).take

Try it online!
Ungolfed:
ungolfed :: Int -> Double -> Double -> [Double]
ungolfed len x1 x2 = take len $ go (cycle [(+),(*),(-),(/)]) x1 x2
    where go (f:fs) x y = x : go fs y (f x y)

Knowing \x -> f x == f, \x -> f $ g x == f . g, and some other patterns, you can transform a normal (point-full) function into a point-free one:
f0 len x1 x2 = take len $ go p x1 x2
f1 len = \x1 x2 -> take len $ go p x1 x2
f2 len = \x1 -> take len . go p x1
f3 len = (take len .) . go p
f4 = \len -> (. go p) (take len .)
f5 = \len -> (. go p) ((.) (take len))
f6 = \len -> (. go p) . (.) $ take len
f7 = \len -> ((. go p) . (.) . take) len
f8 = (. go p) . (.) . take

\x y -> f $ g x y == (f.) . g is also a common pattern.
You could also read this backwards for adding back arguments to a point-free function.

Welcome to PPCG and nice first answer! I'd appreciate an explanation of the decomposition of (.g p).(.).take into take len $ go p x1 x2

@KritixiLithos To be honest, I used http://pointfree.io, but I've worked it out and added the transformation from point-full to point-free. Hopefully it's clear (and correct) enough.

Common Lisp, 158
(lambda(x y n)(loop repeat n for a = x then b for b = y then r for o in '#1=(+ * - / . #1#)for r =(ignore-errors(funcall o a b))collect(coerce a'long-float)))

Not really competitive, but I like how it is is expressed quite naturally:
(lambda (x y n)
  (loop
    repeat n
    for a = x then b
    for b = y then r
    for o in '#1=(+ * - / . #1#)
    for r = (ignore-errors (funcall o a b))
    collect (coerce a 'long-float)))

We ignore errors when computing R, which makes R (and then B) possibly take the NIL value. That allows to output the current result even if the next value is undefined. Then, eventually the loop will fail, but that's within the rules.
Tests
We name the function F and verify that the expected values are approximately equal to the tested one.
(loop
  for (args expected)
    in
  '(((1 3 8)
     (1 3 4 12 -8 -1.5 -9.5 14.25))

    ((0 1 5)
     (0 1 1 1 0))

    ((1 0 9)
     (1 0 1 0 1 0 1 0 1))

    ((6 3 25)
     (6 3 9 27 -18 -1.5 -19.5 29.25 -48.75 -0.6 -49.35 29.61 -78.96 -0.375 -79.335 29.7506 -109.086 -0.272727 -109.358 29.825 -139.183 -0.214286 -139.398 29.8709 -169.269)))

  for result = (apply #'f args)
  always (every (lambda (u v) (< (abs (- u v)) 0.001)) result expected))

=> T

The reason for the approximate test is because the computed values are a little more precise than required; here, for (f 6 3 25):
(6.0d0 3.0d0 9.0d0 27.0d0 -18.0d0 -1.5d0 -19.5d0 29.25d0 -48.75d0 -0.6d0
 -49.35d0 29.61d0 -78.96d0 -0.375d0 -79.335d0 29.750625d0 -109.085625d0
 -0.2727272727272727d0 -109.35835227272727d0 29.825005165289255d0
 -139.18335743801654d0 -0.21428571428571427d0 -139.39764315230224d0
 29.870923532636194d0 -169.26856668493843d0)

dc, 112 110 108 bytes
5k?sarfsmsn[pSnla1-Sa]sh[lmlndSm]sv[lvx/lhx]sb[lvx+lhx]sc[lvx*lhx]sd[lvx-lhx]se[lcx2la>d2la>e2la>b2la>j]dsjx

Sometimes dc answers can be super long, and sometimes they can be super short. It all just depends on the challenge at hand as is the case with many other languages. Anyways, this prompts for a space-separated one-indexed command line input of 3 integers, x(1), x(2), N, upon invocation, and outputs each element of the sequence on separate lines with non-integer outputs containing 5 digits after the decimal point.
For example, the input 6 3 25 results in the following output:
6
3
9
27
-18
-1.50000
-19.50000
29.25000
-48.75000
-.60000
-49.35000
29.61000
-78.96000
-.37500
-79.33500
29.75062
-109.08562
-.27272
-109.35834
29.82420
-139.18254
-.21428
-139.39682
29.86995
-169.26677

Perl, 62 + 3 (-pla flag) = 65 bytes
push@F,eval$F[-2].qw(* - / +)[$_%4].$F[-1]for 3..pop@F;$_="@F"

Using:
perl -plae 'push@F,eval$F[-2].qw(* - / +)[$_%4].$F[-1]for 3..pop@F;$_="@F"' <<< '1 3 8'

05AB1E, 12 bytes
λ£"-/+*"Nè.V

Try it online!

C++14, 118 bytes
[](auto&v,int N){for(int i=0;++i<N-1;){auto p=v.rbegin(),q=p+1;v.push_back(i%4?i%4<2?*q+*p:i%4<3?*q**p:*q-*p:*q/ *p);}

As unnamed lambda modifying its input. Requires v to be a vector<double> or vector<float>.
Ungolfed and usage:
#include<iostream>
#include<vector>

auto f=
[](auto&v,int N){
  for(int i=0; ++i<N-1;){
    auto p=v.rbegin(),q=p+1;
    v.push_back(
      i%4 ?
        i%4<2 ? *q+*p :
          i%4<3 ? *q**p : *q-*p
      : *q/ *p
    );
  }
};

int main(){
  std::vector<double> v={1,3};
  f(v,8);
  for (auto x:v) std::cout << x << ", ";
  std::cout << "\n";
}

Bash, 224 bytes (NO CONTEST)
A tremendously large implementation in BASH.
Takes the task quite literally, and does everything in one continuous pipe,
w/o any unholy control flow structures or recursion.
Input

$1,$2 - initial elements
$3 - target sequence size

Golfed
{ echo "a[0]=$1;a[1]=$2;a[0];a[1]";paste <() <(seq 2 $[$3-1]) <(seq 0 $[$3-3]) <(printf '%.0s+*-/' `seq $[$3/4]`|fold -1|head -$[$3-2]) <(seq 1 $[$3-2]);}|sed -r '1 ! s/(.+)\s(.+)\s(.+)\s(.)/a[\1]=a[\2]\3a[\4];a[\1];/'|bc -l

Less Golfed
{
 echo "a[0]=$1;a[1]=$2;a[0];a[1]";
 paste <() <(seq 2 $[$3-1]) <(seq 0 $[$3-3]) <(printf '%.0s+*-/' `seq $[$3/4]`|fold -1|head -$[$3-2]) <(seq 1 $[$3-2]);
}\
|sed -r '1 ! s/(.+)\s(.+)\s(.+)\s(.)/a[\1]=a[\2]\3a[\4];a[\1];/' \
|bc -l

Test
>./stewie.sh 1 3 8
1
3
4
12
-8
-1.50000000000000000000
-9.50000000000000000000
14.25000000000000000000

Pipeline Stages
Generate a table of element indices + op, for an each output sequence element (one per line):
...
2   0   +   1
3   1   *   2
4   2   -   3
5   3   /   4
6   4   +   5
7   5   *   6
...

Use sed to convert this into a linear bc program:
...
a[2]=a[0]+a[1];a[2];
a[3]=a[1]*a[2];a[3];
a[4]=a[2]-a[3];a[4];
a[5]=a[3]/a[4];a[5];
a[6]=a[4]+a[5];a[6];
a[7]=a[5]*a[6];a[7];
...

feed this to bc and let it do all the job

Ruby, 79 bytes
->(b,c,d){a=[b,c];(d-2).times{|i|a<<a[i].send(%i{+ * - /}[i%4],a[i+1]).to_f};a}

I suspect this is very far off from optimal (and I haven't looked at the other answers yet), but it's fun nonetheless.
I wanted to have some fun with Enumerable#cycle, but sadly, it's 4 fewer characters to just use %4.

Japt, 20 bytes
@OxVs2n)q"-/+*"gY}hV

Try it

J, 49 33 29 bytes
[$_2&(],(-,%,+,*)/@{.{~4|#@])

Try it online!
-4 bytes thanks to FrownFrog

[$_2&(],(-,%,+,*)/@{.{~4|#@])

Tyvm!  I always forget about that little trick with Bond.

PowerShell, 66 60 58 bytes
-8 bytes thanks to mazzy
param($a,$b)3..$a|%{$b+=$b[-2,-1]-join"*-/+"[$_%4]|iex}
$b

Try it online!
Builds x(n) in place by making a string out of x(n-2) and x(n-1), joined by the operator we need (determined by modulo math using the index we get for free from iterating up), and feeds it into invokeExpression. We then spit out the final array.

nice! $b is array, so you don't need brackets ,(...). Try it online!

@mazzy Ah, cheers. Smart move on the join as well.

also we can remove ++ Try it online!

@mazzy Oh yeah, guess we do already have something counting up. Nice

Ceylon, 195 bytes
Float[]s(Integer a,Integer b,Integer n)=>loop([a.float,b.float,[Float.divided,Float.plus,Float.times,Float.minus].cycled.rest])(([x,y,o])=>[y,(o.first else nothing)(x)(y),o.rest]).take(n)*.first;

Formatted and commented:
// Print the first n entries of the Stewies sequence with given starting entries.
//
// Question:  http://codegolf.stackexchange.com/q/101145/2338
// My answer: http://codegolf.stackexchange.com/a/101251/2338

// Declare a function `s` which takes three integers, and returns a tuple
// of floats. (The more common syntax for the return value is [Float*],
// but Float[] is shorter.)
Float[] s(Integer a, Integer b, Integer n)
       // it is implemented by evaluating the following expression for each call.
         =>
        // start a loop with ...
        loop([
              // ... float versions of the integers, and ...
              a.float, b.float,
              // ... an infinite sequence of the four operators, ever repeating.
              // I needed the `.rest` here so the whole thing gets a {...*} type
              // instead of {...+}, which doesn't fit to what o.rest returns.
              // Each operator has the type Float(Float)(Float), i.e. you apply
              // it twice to one float each to get a Float result.
              [Float.divided, Float.plus, Float.times, Float.minus].cycled.rest])
               // in each iteration of the loop, map the triple of two numbers
               // and a sequence of operators to a triple of ...
            (([x, y, o]) => [
               // the second number,
                y,
               //the result of the first operator with both numbers
               // (using this "else nothing" here to convince the
               //  compiler that o.first is not null),
                   (o.first else nothing)(x)(y),
               // and the sequence of operators without its first element.
               // (that one unfortunately has a {...*} type, i.e. a possibly
               //  empty sequence.)
                                                 o.rest])
            // now we got an infinite sequence of those triples.
            // We just want the first n of them ...
                .take(n)
            // and of each triple just the first element.
            // (The *. syntax produces a tuple, non-lazily.
            //  We could also have used .map((z) => z.first)
            //  or .map(Iterable.first) or .map((z) => z[0]), each of
            //  which would return a (lazy) sequence, but they all would be
            //  longer.)
                *.first;

Example usage:
shared void run() {
    print(s(1, 3, 8));
    print(s(0,1,11));
    print(s(1,0,9));
    print(s(6, 3, 29));
}

Example output:
[1.0, 3.0, 4.0, 12.0, -8.0, -1.5, -9.5, 14.25]
[0.0, 1.0, 1.0, 1.0, 0.0, Infinity, Infinity, Infinity, NaN, NaN, NaN]
[1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
[6.0, 3.0, 9.0, 27.0, -18.0, -1.5, -19.5, 29.25, -48.75, -0.6, -49.35, 29.61, -78.96000000000001, -0.37499999999999994, -79.33500000000001, 29.750625, -109.08562500000001, -0.2727272727272727, -109.35835227272727, 29.825005165289255, -139.18335743801651, -0.2142857142857143, -139.39764315230224, 29.870923532636194, -169.26856668493843, -0.17647058823529413, -169.44503727317374, 29.90206540114831, -199.34710267432206]

The second example shows how this would handle division by zero.
The last example shows that the results deviate a bit depending on which kind of arithmetic (and rounding) one is using ... I think Ceylon's 64 bit  floating point arithmetic is a bit nearer to what it should be than what was posted in the question.

Clojure, 99 bytes
#(let[ops[+ * - /]](take %3(map first(iterate(fn[[a b i]][b((ops i)a b)(mod(inc i)4)])[%1 %2 0]))))

This version is nicer to use in practice but has 110 bytes:
(defn f[a b n](let[ops[+ * - /]](take n(map first(iterate(fn[[a b i]][b((ops i)a b)(mod(inc i)4)])[a b 0])))))

I had trouble fuzing iterated function and a cyclical sequence of operations so I had to use a counter instead. Also tried using a FSM transition table like {+ * * - - / / +} but I couldn't squeeze it to less code.
Could be expressed as an anonymous function
Un-golfed:
(defn f [a b n]
  (let [ops [+ * - /]]
    (->> [a b 0]
         (iterate (fn [[a b i]]
                    [b
                     ((ops i) a b)
                     (mod (inc i) 4)]))
         (map first)
         (take n))))

Must be called with floats like (f 6.0 3.0 25) as otherwise you get rational numbers out. Alternatively the iteration could be started from [a (float b) 0] which brings some extra characters.

Pyth - 20 bytes
Outputting all n costs me.
u+Gvj@"+*-/"H>2GttEQ

Doesn't work online cuz of eval.

Octave, 91 bytes
@(x,n)eval 'for i=3:n,x(i)=eval([(n=@num2str)(x(i-2)),"*-/+"(mod(i,4)+1),n(x(i-1))]);end,x'

Try it online!
Some golfs:

No parentheses for the first eval call
No concatenations for the first eval call
Inline assignment of *-/+ (not possible in MATLAB)
Combined ' and " to avoid escaping the apostrophes (not possible in MATLAB)
Storing n=@num2str since it's used twice (not possible in MATLAB)

cQuents, 19 bytes
=A,B&Y+Z,YZ,Y-Z,Y/Z

Try it online!
Explanation
Receives three inputs, A B n
=A,B                   first two terms in sequence are A and B
    &                  output first n terms of sequence
     Y+Z,YZ,Y-Z,Y/Z    next terms are Y+Z, then Y*Z, ..., cycling back to beginning after 4th
                       Y and Z are the previous two terms in the sequence


text:
Koalas, Crabs, and Commapillars
Given two positive integers X and Y, output any combination of the following three ASCII-art animals such that the output contains exactly X commas (,) and Y periods (.), if it is possible.

Koala: 1 comma, 2 periods
<.,.>

Crab: 2 commas, 2 periods
,<..>,

Commapillar: 3 or more commas, 1 period
<,,,.>

or <,,,,.> or <,,,,,.> or <,,,,,,.> or <,,,,,,,.> etc.

If no combination of these animals can produce exactly X commas and Y periods, output a single commaleon who will camouflage the failure:
~<.,,>~~

The output animals can be in any amounts and any order. They may be in a string, space or newline separated, or else in a list where each animal is one element.
For example, for X = 7, Y = 5, these would all be valid outputs (separated by empty lines):
<.,.> <.,.> <,,,,,.>

<.,.>
<,,,,,.>
<.,.>

,<..>, <.,.> <,,,,.>

<,,,,.>
,<..>,
<.,.>

,<..>, <,,,.> ,<..>,

[",<..>,", ",<..>,", "<,,,.>"] (list syntax depends on language)

Note that (at least in this example) there are multiple sets of animals than can work. But remember you only need to output any one valid solution, if one exists. The number of animals or number of distinct animals does not matter.
For inputs such as X = 3, Y = 3 or X = 1, Y = 5 where there is no solution, the output will always be
~<.,,>~~

perhaps in a single-element list.
The shortest code in bytes wins.

The koala looks just like that :-)

I created a small programm that outputs the number of combinations for each pair (X, Y). Unfortunately, I could only run it up until (128, 128) because that's about the maximum for __int128 and I was too lazy to use a bignum library. Here is the CSV dump: http://pastebin.com/ght5xkRu the first row and column are the X and Y values

Ruby, 139 bytes
Lambda function, takes x and y as arguments and returns a string
->x,y{c=y-2*n=y-(x>y ?1:0)>>1
x+=-c/2*s=[x-n,c*3].max
x<n||x>n*2?'~<.,,>~~':',<..>, '*(x-n)+'<.,.> '*(2*n-x)+"<%s.> "*c%[?,*s-=c/2*3,?,*3]}

If a solution exists, it can be done with all koalas+commapillars or all koalas+crabs.
The principle is to use a minimum of commapillars. If the number is odd, we use 1 commapillar. if even we use 0 commapillars, unless there are more commas than periods, in which case we use 2.
The number of periods used in noncommapillars (crabs + koalas) is necessarily even, and the number of noncommapillars is half (number of periods)-(number of commapillars). If there are insufficient commas for all koalas, or too many for all crabs, no solution is possible. Otherwise, we return a solution.
Commented in test program
uses "fail" instead of chameleon for clarity
f=->x,y{c=y-2*n=y-(x>y ?1:0)>>1
#n=noncommapillars=y>>1 as they have 2 periods. c=commapillars=y-2*n, 1 for odd y, 0 for even y.
#if x>y there are too many commas to have 0 commapillars for even y. noncommapillars= y-1 >> 1, so 2 commapillars

x+=-c/2*s=[x-n,c*3].max
# s=number of commas allocated to commapillars. x-n to allow all noncommapillars to be koalas, but at least 3 per commapillar.
#-c/2 == -1 if there are commapillars, 0 if not (Ruby truncates toward -inf). Subtract commas for commapillars from x if necessary

x<n||x>n*2?'fail':',<..>, '*(x-n)+'<.,.> '*(2*n-x)+"<%s.> "*c%[?,*s-=c/2*3,?,*3]}
#if x<n (insufficient commas for all koalas) or x>n*2 (too many for all crabs) return fail. Else...
#return string off crabs, koalas, and (using % operator like sprintf) c commapillars (0..2), the second with 3 commas (if present) and the first with the rest.

10.times{|j|10.times{|i|puts "%-20s %s"%[?.*j+?,*i,f[i,j]]}}
#all x,y from 0..9

Output
,                    fail
,,                   fail
,,,                  fail
,,,,                 fail
,,,,,                fail
,,,,,,               fail
,,,,,,,              fail
,,,,,,,,             fail
,,,,,,,,,            fail
.                    fail
.,                   fail
.,,                  fail
.,,,                 <,,,.>
.,,,,                <,,,,.>
.,,,,,               <,,,,,.>
.,,,,,,              <,,,,,,.>
.,,,,,,,             <,,,,,,,.>
.,,,,,,,,            <,,,,,,,,.>
.,,,,,,,,,           <,,,,,,,,,.>
..                   fail
..,                  <.,.>
..,,                 ,<..>,
..,,,                fail
..,,,,               fail
..,,,,,              fail
..,,,,,,             <,,,.> <,,,.>
..,,,,,,,            <,,,,.> <,,,.>
..,,,,,,,,           <,,,,,.> <,,,.>
..,,,,,,,,,          <,,,,,,.> <,,,.>
...                  fail
...,                 fail
...,,                fail
...,,,               fail
...,,,,              <.,.> <,,,.>
...,,,,,             <.,.> <,,,,.>
...,,,,,,            <.,.> <,,,,,.>
...,,,,,,,           <.,.> <,,,,,,.>
...,,,,,,,,          <.,.> <,,,,,,,.>
...,,,,,,,,,         <.,.> <,,,,,,,,.>
....                 fail
....,                fail
....,,               <.,.> <.,.>
....,,,              ,<..>, <.,.>
....,,,,             ,<..>, ,<..>,
....,,,,,            fail
....,,,,,,           fail
....,,,,,,,          <.,.> <,,,.> <,,,.>
....,,,,,,,,         <.,.> <,,,,.> <,,,.>
....,,,,,,,,,        <.,.> <,,,,,.> <,,,.>
.....                fail
.....,               fail
.....,,              fail
.....,,,             fail
.....,,,,            fail
.....,,,,,           <.,.> <.,.> <,,,.>
.....,,,,,,          <.,.> <.,.> <,,,,.>
.....,,,,,,,         <.,.> <.,.> <,,,,,.>
.....,,,,,,,,        <.,.> <.,.> <,,,,,,.>
.....,,,,,,,,,       <.,.> <.,.> <,,,,,,,.>
......               fail
......,              fail
......,,             fail
......,,,            <.,.> <.,.> <.,.>
......,,,,           ,<..>, <.,.> <.,.>
......,,,,,          ,<..>, ,<..>, <.,.>
......,,,,,,         ,<..>, ,<..>, ,<..>,
......,,,,,,,        fail
......,,,,,,,,       <.,.> <.,.> <,,,.> <,,,.>
......,,,,,,,,,      <.,.> <.,.> <,,,,.> <,,,.>
.......              fail
.......,             fail
.......,,            fail
.......,,,           fail
.......,,,,          fail
.......,,,,,         fail
.......,,,,,,        <.,.> <.,.> <.,.> <,,,.>
.......,,,,,,,       <.,.> <.,.> <.,.> <,,,,.>
.......,,,,,,,,      <.,.> <.,.> <.,.> <,,,,,.>
.......,,,,,,,,,     <.,.> <.,.> <.,.> <,,,,,,.>
........             fail
........,            fail
........,,           fail
........,,,          fail
........,,,,         <.,.> <.,.> <.,.> <.,.>
........,,,,,        ,<..>, <.,.> <.,.> <.,.>
........,,,,,,       ,<..>, ,<..>, <.,.> <.,.>
........,,,,,,,      ,<..>, ,<..>, ,<..>, <.,.>
........,,,,,,,,     ,<..>, ,<..>, ,<..>, ,<..>,
........,,,,,,,,,    <.,.> <.,.> <.,.> <,,,.> <,,,.>
.........            fail
.........,           fail
.........,,          fail
.........,,,         fail
.........,,,,        fail
.........,,,,,       fail
.........,,,,,,      fail
.........,,,,,,,     <.,.> <.,.> <.,.> <.,.> <,,,.>
.........,,,,,,,,    <.,.> <.,.> <.,.> <.,.> <,,,,.>
.........,,,,,,,,,   <.,.> <.,.> <.,.> <.,.> <,,,,,.>

Befunge, 249 218 bytes
&::00p&::00g\`-2/:20p2*-3*:30p\20g-`:!00g20g-*\30g*+:30g-v>:#,_@
"~<.,,>~~"0_v#\g03+`g050`\0:-g02\p05:-\*2g02:-*/6+3g03p04<^
$"<">:#,_40p>:!#|_3-0" >.,,"40g3>3g#<\#-:#1_
0" ,>..<,">:#,_$>:!#|_1-
#@_1-0" >.,.<">:#,_$>:!

Try it online!
This is now based on the algorithm in the Ruby answer by Level River St, which provided greater scope for golfing and a significant reduction in size compared to my original solution.

C#6, 321 303 bytes
using System.Linq;string F(int x,int y)=>S(x,y)??"~<.,,>~~";string S(int x,int y)=>x<0|y<0?null:y<1?x<1?"":null:y*3>x?S(x-1,y-2)!=null?S(x-1,y-2)+"<.,.> ":S(x-2,y-2)!=null?S(x-2,y-2)+",<..>, ":null:string.Concat(new int[y].Select((_,k)=>k<1?C(x-y*3+3):C(3)));string C(int x)=>$"<{new string(',',x)}.> ";

Call F(). The other two functions are helpers. repl.it demo
// Coalesce failed combinations with commaleon
string F(int x,int y)=>S(x,y)??"~<.,,>~~";
// Get successful combination or null
string S(int x,int y)=>
    x<0|y<0
        // Fail: Out of range
        ?null
        :y<1
            ?x<1
                // Successful: All commas and periods accounted for
                ?""
                // Fail: Not enough periods for commas
                :null
            :y*3>x
                // Not all commapillars
                ?S(x-1,y-2)!=null
                    // Try koala
                    ?S(x-1,y-2)+"<.,.> "
                    // Try crab
                    :S(x-2,y-2)!=null
                        ?S(x-2,y-2)+",<..>, "
                        // Epic fail
                        :null
                // All commapillars
                :string.Concat(new int[y].Select((_,k)=>k<1
                    // This commapillar takes most of commas
                    ?C(x-y*3+3)
                    // The rest each takes 3
                    :C(3)));
// Generate single commapillar
string C(int x)=>$"<{new string(',',x)}.> ";

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Tips for creating polyglots
A polyglot is a program that can be run in 2 or more different programming languages.
What general tips do you have for making polyglots, or choosing languages that are easy to write polyglots for a specific task?
Please post the tips that could be applied in most situations. I.e. they shouldn't work only in polyglots of two specific languages. (You could simply post an answer to a polyglot question if you have a too specific tip.) But you can introduce features of a language that makes it easy to work with many languages, or easy to be added to any existing polyglots.
Please post one tip per answer. And feel free to suggest edit if a language-specific tip also applies to another language.

Use two-dimensional languages
Unlike one-dimensional languages, which generally parse the entire source code and will produce syntax errors or unwanted runtime effects on things they don't understand (thus forcing you to hide other languages' code from them), two-dimensional languages tend to only parse code in the path of execution, meaning that the entire rest of the program is ignored. There's also a lot more room to split execution paths away from each other in two dimensions; you can send the instruction pointer turning in an unusual direction, like down or even left (wrapping round to the right hand side of the program), to get it out of your way very quickly. The techniques useful in one-dimensional languages also generalise to two-dimensional languages (e.g. you can skip over code with ;; in Befunge-98, in addition to just sending the IP in a weird direction), making this mostly just a strict gain compared to a one-dimensional solution.
As a bonus, several two-dimensional languages have an entry point other than the top-left of the program, meaning that you don't need to go to any effort to split them away from other languages; they'll split themselves off from the group naturally.

Exploit comment symbols
A simple way to create a two-language polyglot is to have the code divided in two parts as follows:

The first part does the actual work in language A, is harmless in language B (no errors), and ends in a language-A comment symbol, which hides the second part to language A.
The second part does the actual work in language B.

Thus

Language A sees the first part, which does the job, and then a comment.
Language B sees a useless first part and then the second part, which does the job.

The only difficult part here is finding a set of statements (first part) that do the job in language A while not giving errors in language B. Some suggestions for this:

Most stack-based languages allow displaying only the top of the stack at the end of the program (sometimes this is even default, as in 05AB1E).
Some languages ignore undefined statements (for example Golfscript).

A simple example that uses these guidelines can be found here. Languages A and B are MATL and 05AB1E respectively.

Know your Trues and Falses
Each language sees "true" and "false" in a slightly different way. If they have similar syntax, you can exploit this by adding a decision that the languages will handle differently.
One example from the Trick or Treat thread uses '', an empty string. In Lua, this evaluates to truthy, but falsy in Python, so the following:
print(''and'trick'or'treat')

..will print a different string in each language.
All it takes is finding a value like this. For example, you could use '0', which evaluates to false in PHP but true in Python.

Blockquotes in at least one language
Here's an example that works both in Python and C++
#include <iostream> /*
""" */
int main() {
    std::cout << "Hello World!\n";
}

/* """
print("Hello World!")
# */

Luis Mendo pitched what I think is by far the easiest solution, which is to use comments.
You look for one language that has block commenting and another language where regular syntax in the first is commenting syntax in the second.
Even easier is two languages with different block commenting styles that are interchangeably correct syntax, but I couldn't be bothered to check.
Check it out in Python 3.5 and C++

The first line there shouldn't have a semicolon.

True. Good point

Divide and conquer
When you're writing a polyglot in a large number of languages, you won't necessarily be able to separate all the language's control flows from each other immediately. Thus, you'll need to "true polyglot" some of the languages for some length of time, allowing the same code to run in each of them. There are two main rules to bear in mind while you're doing this:

The control flow in any two languages should either be very similar, or very different. Trying to handle a large number of interleaved control flows is a recipe for getting confused and makes your program hard to modify. Instead, you should limit the amount of work you have to do by ensuring that all the programs that are in the same place are there for the same reason and can happily be run in parallel for as long as you need them to be. Meanwhile, if a language is very different from the others, you want its execution to move to a very different location as soon as possible, so that you don't have to try to make your code conform to two different syntactic models at once.
Look for opportunities to split one language, or a group of similar languages, away from each other. Work from larger groups down to smaller groups. Once you have a group of similar languages all at a certain point in the program, you'll need to split them up at some point. At the start of the program, you might well, say, want to split the languages that use # as a comment marker away from languages that use some other comment marker. Later on, perhaps you have a point where all languages use f(x) syntax for function calls, separate commands with semicolons, and have similar syntactic similarities. At that point, you could use something much more language-specific to split them, e.g. the fact that Ruby and Perl don't process escape sequences in '' strings, but Python and JavaScript do.

In general, the logical flow of your program should end up as a tree, repeatedly splitting into groups of languages that are more similar than each other. This puts most of the difficulty in writing the polyglot right at the start, before the first split. As the control flow branches out more and more, and the languages that are running at any given point get more and more similar, your task gets easier because you can use more advanced syntax without causing the languages involved to syntax-error.
A good example is the set {JavaScript, Ruby, Perl, Python 3}; all these languages accept function calls with parentheses and can separate statements with semicolons. They also all support an eval statement, which effectively allows you to do flow control in a portable way. (Perl is the best of these languages to split off from the group early, because it has a different syntax for variables from the others.)

Hide code inside string literals
In most languages, a string literal on its own either does nothing, or does something that can be easily reversed (such as pushing the string onto the stack). String literal syntax is also relatively nonstandardised, especially for the alternative syntaxes that many languages use to handle strings with embedded newlines; for example, Python has """ ... """, Perl has q( ... ), and Lua has [[ ... ]].
There are two main uses of these. One is to allow you to interleave sections intended for different languages via starting a string at the end of one language's first section and resuming it at the start of the second: it should be fairly easy to avoid accidentally closing the string due to the variety of string delimiters among different languages. The other is that many string delimiters happen to be meaningful as a command in other languages (often more so than comment markers), so you can do something like x = [[4] ], which is a harmless assignment in languages which use JSON notation for lists, but which starts a string in Lua (and thus allows you to split the Lua code from the rest, given that it effectively "jumps" to the next ]]).

Variable or code inside string literals
Double-quoted string literals are mostly harmless in many languages. But in some languages they could also contain code.
In Bash, you can use `...` (it doesn't end the program):
"`echo Hello world! >/proc/$$/fd/1`"

In Tcl, you can use [...]:
"[puts {hello world!};exit]"

In PHP, you can use ${...} (this generates an error in Bash so it must appear after the Bash code):
"${die(print(Hello.chr(32).world.chr(33)))}";

In Ruby, you can use #{...}:
"#{puts 'Hello world!';exit}"

There might be also others.
These grammars aren't compatible. That means you can put all the code of these languages in one string in a harmless location. And it will just ignore the unrecognized code in other languages and interpret them as string content.
In many cases, you could also easily comment out a double quote character there and make a more traditional polyglot.

#-based comments
This tip is a subset of Exploit comment symbols and Blockquotes in at least one language
When creating polyglots with many languages, especially production-ready languages as opposed to esolangs, it can be useful to look at the languages which use # in block or single-line comments.

There are many languages with block comment syntaxes starting with #, and there's a lot of variety in the chars following the #.
Most of these languages also allow a single # as a line comment, which means that something which might start a block comment in one language is just an ordinary comment in another, making it easy to fit in.

Here's a quick summary list of languages which use # in a block comment (not exhaustive):
Language            Start       End      Single-line #?     Notes
------------------------------------------------------------------------------------------
Agena               #/          /#             ✓
AutoIt              #cs         #ce
Brat                #*          *#             ✓
C                   #if 0       #endif                      Not actually a comment
CoffeeScript        ###         ###            ✓            Needs to be on separate line
Common Lisp         #|          |#
Julia               #=          =#             ✓
Lily                #[          ]#             ✓
Objeck              #~          ~#             ✓
Perl 6              #`{         }#             ✓            Any bracketing chars will do
Picolisp            #{          }#             ✓
Scheme              #|          |#

For more examples, see Rosetta Code.
Here's a quick and easy example, as a demonstration:
#|
###
#`[

print("Julia")
#=

|#
(format t "Common Lisp")
#|

###
alert("CoffeeScript")
###

]#
say "Perl 6"
#`[

...

# ]# # ### # |# ; =#

Zephyr has #- ... -#.

Variable Aliasing
This is probably one of the simplest yet (IMO) most important tricks to use, especially since it can reach so many languages.
Example:
print=alert;print("Hello World!")

This will work in not only Javascript, but also Python, Ruby, etc. More examples later when I think of some others. Of course, comment suggestions/post edits are welcome.

Note that when doing e.g. JS/Python, it's usually shorter to alias alert to print in Python (3 only) because JS's comment syntax, //, can be easily worked into a Python program, while Python's # can't be worked into JS.

Ending the program
You can end the program abruptly in one language so that it will ignore the code in another language.
So basically this format can be used
code_in_language1 end_program_in_language1 code_for_language2 end_program_in_language2 ...

where end_program_in_languageN is the command for ending the program.
For example, in my answer in What will you bring for Thanksgiving?, I ended the program in Dip, and then I wrote code for another language, V, so that the Dip interpreter would ignore it.
"turkey"e#"corn"??"gravy"p&Ssalad
"turkey"e#"corn"??"gravy"
                         p&            # print stack and exit program (Dip)
                           Ssalad      # Now that the program ended in Dip,
                                       # I can write V code that would otherwise
                                       # have caused errors in Dip

But then, not all languages have a command that can end the program just like that. However, if such a language has the feature, it should be used wisely.
As @LuisMendo suggested, you can create an error (if it is allowed) to end the program if the language does not already have an "end program" builtin.

Even if the language doesn't have a function or statement to end the program, an error usually will do

@LuisMendo: Agreed, although note that many polyglotting problems specifically ban exit-via-crashing because it makes things too easy. It's a good idea to exploit it when they don't, though.

You should probably mention that the second part's code still should be syntactically correct in the first language or else most practical languages will throw an error.

Arithmetic operator discrepancies
For similar languages or simple polyglots, sometimes it's useful to look for differences in how the languages perform arithmetic. This is because most (non-esoteric) languages have infix arithmetic operators and arithmetic can be a quick and easy way to introduce a difference.
For example:

^ is bitwise XOR in some languages and exponentiation in others
/ is integer division in some languages and floating point division in others

For the integer division languages, -1/2 is -1 in some languages (round down) and 0 in others (round to zero)

-1%2 is -1 in some languages and 1 in others
--x is a no-op in some languages (double negation) and pre-decrement in others
1/0 gives infinity in some languages and errors out in others
1<<64 gives 0 in some languages (overflow) and 36893488147419103232 in others

A simple example would be x=1;["JS","Python"][--x], which returns the name of the language it's run in (between JS and Python).

Use Brainfuck
Pretty much all BF implementations cast out chars that aren't +-<>[].,, which just so happens to work in our favor!
BF is probably one of the easiest languages to work into a polyglot because of this feature, as long as you write the BF part first. Once you have your BF code written out, it's just a matter of modeling whatever other code you have around the BF structure.
Here's a really simple example:
.+[.+]

This pretty much increments and charcode-outputs "forever" (depending on runtime settings). Now if you wanted to write a random piece of code, say, in JS, you could do:
x=>"asdf".repeat(+x)[x*Math.random()*2+1|0]

Notice how the JS is molded around the BF.
Be sure to know that this works best if you are really set on starting with BF; it's decently harder to start with another language and try to incorporate BF.

For larger polyglots where a few bytes of savings from integrating the BF doesn't help much, I'd write the BF last and wrap the other code in as many [] as necessary.

This applies not just to brainfuck but to the huge number of brainfuck-similar languages and a lot of other Turing tarpits.

The first x=> changes the cell, which in this case doesn't matter, but just wanted to say

In python you can put code()#[] where code() is the python code and [] is the bf code, since # is a comment in python.

Use languages in which most characters don't matter
This is a generalization of Mama Fun Roll's point about BF. An esolang that ignores most characters is very useful in polyglots. Also useful: an esolang in which a large set of characters are interchangeable. Some examples:

Whitespace ignores everything that isn't space, tab, or newline.
Brain-Flak basically ignores everything besides ()[]{}<>. (@ sometimes causes an error when the interpreter tries to parse it as the start of a debug flag.)
oOo CODE ignores everything except letters. Furthermore, all lowercase letters are interchangeable, as are all uppercase letters.
Wierd only distinguishes between whitespace and non-whitespace characters.
In Wordy, some punctuation characters are ignored, and all letters are interchangeable.
Both Parenthetic and Parenthesis Hell ignore everything except parentheses.

I fixed that @ error.

Try combining Whitespace with Python

@enedil You don't need to have tabs with Python. You can use exec('''...\t\n\40''')

Be Aware of Nested Block Comments
Sometimes multiple languages will use the same syntax for block comments, which is more often than not a deal breaker for creating a polyglot with the two languages. Very occasionally however, one of the languages will allow nested block comments, which can be abused to create separate code paths.
For example, consider this polyglot:
#[#[]#print("Lily")#]#echo"Nim"

Nim and Lily both use #[ and ]# to begin and end block comments, but only Nim allows nested block comments.
Lily considers the second #[ as part of the singular block comment and the first ]# as terminating the block comment. (The # following Lily’s print statement is a line comment that hides Nim’s code.)
Nim alternatively, sees the #[]# as a nested (albeit empty) block comment and print("Lily")# as the outer block comment.

Call nonexistent functions, then exit while evaluating their arguments
Many programming languages are capable of parsing an arbitrary identifier followed by a pair of parentheses with an expressions inside:
identifier(1 + 1)

Sometimes, the form of the identifier in question might be fixed, due to being needed to give code to a different language you're using. That might at first seem to cause trouble, if the identifier doesn't correspond to a function that the language actually has.
However, many programming languages will evaluate a function's arguments before they check to see if the function itself actually exists (e.g. Lua), and so you can use this sort of construct anyway; all you need is to exit the program somewhere inside the function's arguments.
Here's an example, a dc/Lua polyglot:
c2pq(1 + #os.exit(print(3)))

c2pq is a dc program to print 2 and exit; Lua sees this as the name of a function, but Lua can be prevented from erroring via placing an exit command in its argument. The big advantage of this construction is that unlike an assignment (c2pq =), it's not automatically incompatible with languages in which variable names start with a sigil; function name syntax is much more consistent across languages than variable name syntax is.

Not sure if this counts, but...
Use a shebang line to turn everything into a valid perl program
According to this answer and the Perl documentation, if you pass any file that starts with a shebang line to perl, it invokes the appropriate program to run it. For instance, this
#!/usr/bin/python

for i in range(6):
    print i**2

gets executed by the Python interpreter if you call perl filename.py.

While the program can be called with perl, it doesn't become a Perl program.

@PaŭloEbermann I realize that it's borderline, that's why I started my answer with "not sure if it counts". :) But what defines true Perl, if not "what is written in the documentation and returned by the reference implementation perl"? Sounds like a good philosoraptor meme...

(See also this meta answer.)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Tips for golfing in Nim
What general tips do you have for golfing in Nim? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Nim (e.g. "remove comments" is not an answer).
Please post one tip per answer.

Use the future module
The future module contains two main byte-saving features: lambdas and list comprehensions. Lambdas are extremely useful.
For example, this:
proc f(s:any):any=s&", world!"

can be shortened to this:
import future
s=>s&", world!"

which saves a byte. Note, however, that lambdas can't be used outside of a parameter list -- so to test your code, you'll have to do something like this:
import future
proc test(f: string -> string) = echo f "Hello"
test(s=>s&", world!")

As well, list comprehensions can be used with the future module. For example, this code prints a seq (@[...]) of all squares less than 100 divisible by 4:
import future
echo lc[x*x|(x<-1..9,x*x mod 4==0),int]

For a fairer comparison it should be noted that you can sometimes use any instead of string (I'm assuming you chose the longest type name), but this still saves regardless.

@Sp3000 I didn't know you could use any, thanks for the tip! You should post that as an answer.

For an even better comparison, you can do proc(s:any):any=s&", world!", dropping the <space>f for an anonymous proc

The name has been changed to sugar, and future has been deprecated.

I think this change was approx around the 1.x boundary.

Unsigned operators
When working with nonnegative integers, sometimes it's better to use unsigned operators. Specifically, if possible, use /% and %% instead of div and mod.

Flexible call syntax
Nim is pretty flexible when it comes to function call syntax. For example, here are some ways to call a function with one argument:
ord(c)
ord c
c.ord

And ways to call a function with two arguments:
max(a,b)
a.max(b)
a.max b

Choose the golfiest version that works right for your situation, especially regarding precedence. For example, compare:
abs(n)+2
n.abs+2
(abs n)+2

As opposed to:
abs(n+2)
(n+2).abs
abs n+2

Note that max a,b even works (sometimes).

You can also drop the space when followed by a " (quotation mark): len"Hello world!"

Use on and off as a boolean value
on / off are aliases for true / false.

Use ; to end statements
Oftentimes, a lot of Nim bytes come from the mandatory indentation of two spaces. This can sometimes be avoided by utilizing ; to break statements.
For example (a bit contrived, but nevertheless effectively demonstrating the idea):
while 1>0:echo "Hello";echo"World"

1>0 for true and 0>1 for false
In Nim, there is no implicit conversion of int->bool or bool->int. It is thus advantageous for golfing to use 1>0 or 0>1 to get the values for true and false, as one might use 1/0 in C. This can help with, for example, the creation of infinite loops.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Multi-lingual Challenge
After all the fun we've had with polyglot challenges in the (recent) past, how about a challenge where the output can be in two languages?
Your answer needs to accept boolean input b and output the text "true" or "false". The same code needs to output, when run in another language, "waar" or "onwaar" or any other translation of trueand false.
Input

Input is a clearly distinguishable truthy/falsey. Admissible are the actual values T/F, a bit, int or (empty) string.
Input needs to be the same for all parts of your submission.

Output

Output may be returned by a function, written to STDOUT, placed in a popup-window, 3D-printed and mailed etc.
The output needs to represent the state of b. So a 'truthy' needs to output 'true', 'waar' ... and 'falsey' should lead to 'false', 'onwaar', etc.
Different languages may use different output methods.

Languages used

One of your outputs MUST be "true" and "false".
Different versions of programming languages count as different languages for this challenge.
Different dialects of a human language count as different languages for this challenge.
You may extend the polyglot to more than two programming languages. Every programming language needs to output a distinct human language.

The answer with the most languages incorporated will be declared the winner. When tied, bytecount is considered.

Is it intentional that your program can just check the version of the interpeter/compiler its run with?

@CodingLambdas I'm not sure I get what you're saying?

Example with python: import sys; is_py3 = sys.version_info.major == 3.

@CodingLambdas Yes; "Different versions of programming languages count as different languages".

Are "True" and "False" acceptable in place of the required "true" and "false"?

I was asking about the output, RE: '''One of your outputs MUST be "true" and "false".'''

@JonathanAllan My bad. Yes, that's fine for output.

I'd love to see an esolang where the output is 3D-printed and mailed back to you.

This is too broad for a popularity contest. Do X creatively pop cons have fallen out of scope.

@Dennis added win-condition.

If someone manages all the dialects for Chinese...

Dyalog APL, 243 237 bytes: 14 languages, extendable to 131*
-6 bytes thanks to Soaku.
Requires ⎕IO←0 which is default on many systems. Prompts for input of 0 or 1.
((⎕AV⍳'ëáàÆÅÄòðÓÈÇ')⍳⍎⎕D∩⍨4↑1⊃#⎕WG'APLVersion')⊃⎕⊃s¨⌽(s←{1↓¨⍵⊂⍨⍵=⊃⍵})';,true,adevarat,haqiqiy,otito,tunay,bener,prawda,dogru,vrai,that,wahr,vero,verdade,cierto;,false,fals,yolg''on,eke,mali,palsu,falsz,yanlis,faux,sai,falsch',18⍴',falso'

Depending on version (9.0 through 16.0, with minor versions) it outputs in English,
Spanish,
Portuguese,
German,
Vietnamese,
French,
Turkish,
Italian,
Polish,
Sundanese,
Filipino,
Yoruba,
Uzbek, or
Romanian, although without diacritics.
 ⎕AV⍳'ëáàÆÅÄòðÓÈÇ' in the indices of the Atomic Vector (151 142 141 133 132 131 122 121 111 102 101 96)
((...)⍳...) find the position of
 ⍎ the evaluated
 ⎕D∩⍨ intersection of Digits and
 4↑ the four* first characters of
 1⊃ the second element of
 #⎕WG'APLVersion' the version number
(...)⊃ then use that to pick among
⎕⊃ the input'th (0: first; 1: second) element of
s¨ the function s (which we will define shortly) applied to each of
⌽ the reverse of
(s←{...}) s applied to – where s is defined as
 1↓¨ the first character dropped from each of
 ⍵⊂⍨ the argument partitioned where
 ⍵= the characters of the argument are equal to
 ⊃⍵ the argument's first character
';,true,adevarat,...,falsch', this string prepended to
18⍴',falso' eighteen characters taken cyclically from that string
* Since version 12.1, the version number includes build number, so by increasing the number of characters taken from this string, it is easy to cover all 131 Latin script languages.

Very nice answer! And great proof on extensibility.

I count 243 bytes.

@ConorO'Brien Fixed. Thanks.

I know it's late, but you can save few bytes by replacing prawdziwy to prawda and falszywy to falsz. The shorter forms fit better here and give you a better score.

6 languages, 169 bytes
Expects 0\n or 1\n as input, and prints words in:

Python 2 (Dutch vals/waar),
Python 3 (French faux/vrai),
Ruby (English false/true),
CJam (Norwegian usant/sant),
Golfscript (Danish usand/sand),
Befunge-93 (Italian falso/vero).

"#{puts gets>?1;exit}"" "#"& 1v
""
print('vwfvaaarlauasrxi'[int(1/2*4+int(input()))::4])
""#";;;;ri"u">"sant"+o
""""
__END__
]0=~"u">"sand"""#@,,,,"vero"  _"oslaf",,,,,@

False in Danish is falsk.

I'd give you two upvotes for that print statement!

All the Funges, 6 languages, 146 bytes
 Now in 3D!
A vv"faux"0"vrai"mv#<v&#;9*j"kslaf"6j"etke">:#,_@;
; >"otreic"0"oslaf"v^<
&^>"murev"0"muslaf">
&^&<"false"0"true"<
>_>:#,_@
^_^

For clarity I've separated the two planes of code so you can see how they're layered. On disk these two blocks would be separated with a form feed character at the end of the line above.
   h"vals"0"waar"<

The rules did say different versions of a language count as separate languages, so this one is six versions of Funge/Befunge. :)

Befunge-93 (Spanish - cierto/falso) Try it online!
Befunge-96 (Latin - verum/falsum) Try it online!
Befunge-97 (French - vrai/faux) Try it online!
Befunge-98 (English - true/false) Try it online!
Unefunge-98 (Norwegian - ekte/falsk)
Trefunge-98 (Dutch - waar/vals)

Thanks to Dennis, all of the Befunge versions can now be tested online at TIO. There aren't currently working implementations of the Unefunge and Trefunge variants, though, so for those I'd recommend Rc/Funge.
A is ignored in Befunge 93 and 96, but is the About Face command in 97 and is unsupported in 98 and thus reflects. This means that 93 and 96 follow the v downwards while 97 and 98 wrap around to the opposite side of the playfield.
In Befunge 96 a ; followed by space at the start of the line marks it as a comment, so that line is skipped and the interpreter continues to the > on the third line. In 93, though, the interpreter follows the > on the second line.
The 97/98 path continues on the first line from right to left, skipping over the section inside the ; comment markers, bridges the & command, eventually reaching the U-bend sequence v<^<. In Unefunge, these direction changes aren't supported so the interpreter reverses direction and executes the previously skipped section in the comments. In Befunge/Trefunge it continues to the left.
In Befunge 97 the m command is unsupported and thus skipped, so the interpreter continues along the first line. In 98 it's 3D-only so it reflects in Befunge (2D) and the interpreter follows the v to the right of it down to the fourth line. In Trefunge (3D) it's a High-Low branch which transfers up a level along the z-axis to the second plane.
So other than the Unefunge case, we have each version gathering their string pair from a separate line before being directed to one of the & commands to get the user input. Those code paths then all merge together via the ^ commands in the second column, directing the program flow upwards through the top of the playfield, wrapping around to the bottom again.
Finally we have the ^_^ sequence which decides which path to follow based on the user input. If 0, we go straight to the output sequence (>:#,_) writing out the false string. If 1, we first execute >_ which clears the first string off the stack, and thus output the true string.

An explanation would be helpful

Very nice answer; using all different versions of the same language really makes this subtle.

5 languages, 249 bytes
Note: the \r and \e are literal line-feed and escape characters, but \x5b has to be as-is otherwise Ruby complains about the character class in the regex.
A bit late to the party, and not a winner by any means, but I started working on a polyglot for the thanksgiving challenge and felt it might be a bit late so transformed it into this!
q=0//1;'''<?die("\r\e\x5bK".(fgetc(STDIN)?Ekte:Falsk));?>/.to_s.ord;def input()gets.to_i;end;q=+q+0;True="Vrai";False="Faux";'+;sub a{<><1?Vals:Waar}q-
input=prompt;print=alert;True="Vero";False="Falso"//'#'''
a=[False,True];b=input();1-+1;print(a[b])

Explanation
Python: True / False
q=0//1;'''<?die("\r\e\x5bK".(fgetc(STDIN)?Ekte:Falsk));?>/.to_s.ord;def input()gets.to_i;end;q=+q+0;True="Vrai";False="Faux";'+;sub a{<><1?Vals:Waar}q-
input=prompt;print=alert;True="Vero";False="Falso"//'#'''
a=[False,True];b=input();1-+1;print(a[b])

Here we set q to 0//1 which is 0, then we have a ''' string that contains most of the other code, store an array containing False and True and indicies 0 and 1 respectively, assign the input to b (which should be 0 or 1 to signify Falsy and Truthy) then print the bth index of a, showing False or True.

Ruby: Vrai / Faux
q=0//1;'''<?die("\r\e\x5bK".(fgetc(STDIN)?Ekte:Falsk));?>/.to_s.ord;def input()gets.to_i;end;q=+q+0;True="Vrai";False="Faux";'+;sub a{<><1?Vals:Waar}q-
input=prompt;print=alert;True="Vero";False="Falso"//'#'''
a=[False,True];b=input();1-+1;print(a[b])

As with the Python script, we set the variable q, but in Ruby this is set to 0 / /1;'''<?die("\r\e\x5bK".(fgetc(STDIN)?Ekte:Falsk));?>/.to_s.ord, as Ruby breaks this down as 0/ as "zero divided-by" and the following / as "beginning of regex literal". Using this literal I'm able to conceal the PHP code and begin Python's '''. We have to add .to_s.ord because the right operand to / has to be a Fixnum. After this we define a function input() and the variable True and False to contain their French counterparts and finally start a string ' which continues onto the next line. Finally we create an array a which contains "Vrai" and "Faux" and select them using the input()ed number 0 or 1.

Perl: Waar / Vals
'0//1;\'\'\'<?die("\r\e\x5bK".(fgetc(STDIN)?Ekte:Falsk));?>/.to_s.ord;def input()gets.to_i;end;q}+q{0;True="Vrai";False="Faux";\'';sub a{<><1?Vals:Waar}'
input=prompt;print=alert;True="Vero";False="Falso"//\'#\'\'\'
a=[False,True];b=input();1'+1;print(a[b])

In Perl, the q=..=, q+...+ and q-...- blocks are quoted literals using unusual delimiters, in the code above I've replaced these with '...'. Most of the code is contained in a literal string, but we do define sub a (which contains a <><!) that checks if STDIN is less than 1, returning either Waar or Vals. The print(a[b]) actually prints the result of calling the sub a with and argument of [b] which is an ArrayRef that contains the bare-word b.

JavaScript: Vero / Falso
q=0//1;'''<?die("\r\e\x5bK".(fgetc(STDIN)?Ekte:Falsk));?>/.to_s.ord;def input()gets.to_i;end;q=+q+0;True="Vrai";False="Faux";'+;sub a{<><1?Vals:Waar}q-
input=prompt;print=alert;True="Vero";False="Falso"//'#'''
a=[False,True];b=input();1-+1;print(a[b])

The first line is mostly commented out by the division 0//1 (// is line comment in JavaScript) so we just set q to 0. The next line deals with mapping the JS functions to their Python names and setting variables True and False to be the Italian strings, finally we execute the same as the Ruby code, setting a to an array of the Italian words and selecting using an input of 0 or 1.

PHP: Ekte / Falsk
die("\r\e\x5bK".(fgetc(STDIN)?Ekte:Falsk));

Since PHP only executes code between <?...?> everything else is output as-is, so our code here simply prints a line-feed (to put us back to the beginning of the current line) and the ANSI escape sequence to clear to the end of the current line, followed by either Ekte or Falsk depending on whether the input char (0 or 1) is truthy or falsy.

C#, Java, 104 Bytes
Golfed:
String M(Boolean b){String s=b+"";if(s=="True")return "Wahr";if(s=="False")return "Falsch";return b+"";}

Ungolfed:
  class MultiLingualChallenge
  {
    public String M(Boolean b)
    {
      String s = b + "";
      if (s == "True")
        return "Wahr";
      if (s == "False")
        return "Falsch";
      return b + "";
    }
  }

Test:
C#
Console.WriteLine(new MultiLingualChallenge().M(true));
//Wahr
Console.WriteLine(new MultiLingualChallenge().M(false));
//Falsch

Java
System.out.println(new MultiLingualChallenge().M(true));
//true
System.out.println(new MultiLingualChallenge().M(false));
//false

Explanation:
When calling ToString() or toString() on a Boolean in C# and Java respectively, C# prints the string with a capital first letter, True and False, but Java prints all in lower case true and false.
Console.WriteLine(true+"");
//True

System.out.println(true+"");
//true

Pyth, Python - 28 bytes
#>"onwaar"yQ.q
print input()

You can save a byte by getting rid of .q and adding a ;at the end.

@TheBikingViking I don't think so, that would make it an infinite loop.

Test

2 languages, 60  bytes
print('onwaar'[2*int(input()):]);1#¶ị“¡ẈẆ“⁸1»

Languages are:

Jelly true false
Python3 waar onwaar

Note: There are UTF-8 bytes, not Jelly bytes.

Lua/JavaScript, 68 bytes
x=1//1print(...and"true"or"false")
--x;alert(prompt()?"vrai":"faux")

Don't know why I golfed it; I just felt like it.

JavaScript / BF
In both these languages, no input is considered as false and any input is considered true.
When you see the structure of the program rotated 90 degrees to the left, the BF symbols look like towers in a city :)
Try it online (BF true testcase)!
Try it online (BF false testcase)!

console.log(prompt()?"true":"false")
/*
           >,[>
+          <<]>>[->-<]
+          >[<->[-]]<>[-]<[>>
+++        [->
++++       <]>[->
++++++++++ <]>---.>]>
++++++++++ [->
++++++++++ <]
+++        [->
+++++      <]>.<
++++       [->----<]>--.<
+++        [->
++++       <]>
+          .<
+++        [->---<]>-.
*/

Explanation
JavaScript
If the prompt is true (ie not empty because prompt returns a string), outputs true, or else outputs false.
BF
Outputs sand (Danish for true) if there is an input, or else outputs usand (false) if the input is empty.
TL;DR If input is not empty (ie true), don't output anything. If input is empty (ie false), output u. Then, regardless whether the input is true or false, output sand.
I have taken inspiration from https://esolangs.org/wiki/Brainfuck_algorithms with which I constructed the logic of my program.
Take input. If input is not empty, increment memory, let's call this cell "Cell A". End if-statement
>
,[
>+
<<
]>

Compares the value of "Cell A" with 0. If they are equal, let "Cell B" be 1, or else let it be 0.
>
[->-<]+>[<->[-]]<

If "Cell B" is 1, then output u. Close if-statement
>[-]<
x[>>
+++[->++++<]>[->++++++++++<]>---.
>]

Output sand
>
++++++++++[->++++++++++<]+++[->+++++<]>.
<++++[->----<]>--.
<+++[->++++<]>+.
<+++[->---<]>-.

For the BF version, shouldn't it output u conditionally, not s?

@AlexL. It does output u conditionally

Oh. I got confused because the explanation says that it outputs s conditionally; could you fix that for clarity? Nice answer anyway.

If input is empty (ie false), output `s`. I think that is the part which got Alex L. confused.

@AlexL. I noticed the mistake, I edited it now!

Haskell, JavaScript, Python, 115 Bytes
q=1//1#1;f True="waar";f False="false";a//b=0;a#b=0{-
1//1;f=lambda x:"wahr"if x else"falsch";"""
f=x=>x+[]//"""#-}


text:
All the Xenodromes
Introduction
A xenodrome in base n is an integer where all of its digits in base n are different. Here are some OEIS sequences of xenodromes.
For example, in base 16, FACE, 42 and FEDCBA9876543210 are some xenodromes (Which are 64206, 66 and 18364758544493064720 in base 10), but 11 and DEFACED are not.
Challenge
Given an input base, n, output out all xenodromes for that base in base 10.
The output should be in order of least to greatest. It should be clear where a term in the sequence ends and a new one begins (e.g. [0, 1, 2] is clear where 012 is not.)
n will be an integer greater than 0.
Clarifications
This challenge does IO specifically in base 10 to avoid handling integers and their base as strings. The challenge is in abstractly handling any base. As such, I am adding this additional rule:
Integers cannot be stored as strings in a base other than base 10.
Your program should be able to theoretically handle reasonably high n if there were no time, memory, precision or other technical restrictions in the implementation of a language.
This is code-golf, so the shortest program, in bytes, wins.
Example Input and Output
1  # Input
0  # Output

2
0, 1, 2

3
0, 1, 2, 3, 5, 6, 7, 11, 15, 19, 21

4
0, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 18, 19, 24, 27, 28, 30, 33, 35, 36, 39, 44, 45, 49, 50, 52, 54, 56, 57, 75, 78, 99, 108, 114, 120, 135, 141, 147, 156, 177, 180, 198, 201, 210, 216, 225, 228

is there a limit to n?

@Flp.Tkc No. It should be able to handle reasonably high n. I don't want the challenge to be limited by how high a base the builtin base conversion of a language can handle.

@Artyer That should have been part of the challenge text, then. It seems some answers are already doing that

I know the base conversion in Pyth can handle values larger that 36, but since this wants all of the xenodromes, the underlying python breaks when the list gets too large, saying it can't fit a value in a ssize_t. Is it breaking in this way acceptable?

@FryAmTheEggman Yes. The algorithm is not the problem there, but the implementation, which is ok.

Somebody seems to have downvoted all answers that cannot handle larger bases because of a built-in precision limit, which also seems like an implementation rather than an algorithm problem. Could you clarify?

@Dennis I have clarified the rules. I think the new rule about ints as strings is what I wanted. I will post in the sandbox next time though.

I didn't downvote, but certainly the answers didn't fulfill that requirement. I think it's better to relax that requirement, as you have done now

Most languages that allow arbitrarily large integers (like Python, which the current winning solution in Pyth is based on) store them internally as strings in base 256 or base 2^32 or something similar. Also, if fixed-length strings still count as strings, then technically everything on a computer is stored as strings of base 2 digits. Perhaps you should at least clarify whether using built-in bignum implementations or libraries is allowed, or whether we need to either stick to fixed-length integers or implement our own large integer arithmetic in base 10?

Pyth, 8 bytes
f{IjTQU^

Filters the numbers in [0, n^n - 1] on having no duplicate elements in base n. The base conversion in Pyth will work with any base, but since this looks at a very quickly increasing list of numbers, it will eventually be unable to store the values in memory.
Try it online!
Explanation:
f{IjTQU^QQ    - Auto-fill variables
      U^QQ    - [0, n^n-1]
f             - keep only those that ...
 {I           - do not change when deduplicated
   jTQ        - are converted into base n

Wow, a solution that's shorter than the Jelly solution that Dennis made! :'P

No one beats Jelly. ¶:

Jelly, 9 8 bytes
ð*ḶbQ€Qḅ

Thanks to @JonathanAllan for golfing off 1 byte!
Try it online! or verify all test cases.
How it works
ð*ḶbQ€Qḅ  Main link. Argument: n

ð         Make the chain dyadic, setting both left and right argument to n.
          This prevents us from having to reference n explicitly in the chain.
 *        Compute nⁿ.
  Ḷ       Unlength; yield A := [0, ..., nⁿ - 1].
   b      Convert each k in A to base n.
    Q€    Unique each; remove duplicate digits.
      Q   Unique; remove duplicate digit lists.
       ḅ  Convert each digit list from base n to integer.

Python 2, 87 bytes
n=input()
for x in range(n**n):
 s={n};a=x
 while{a%n}|s>s:s|={a%n};a/=n
 print-~-a*`x`

Prints extra blank lines for non-xenodromes:
golf % python2.7 xenodromes.py <<<3
0
1
2
3

5
6
7

11

15

19

21

Jelly, 12 bytes
*`ḶbµQ⁼$Ðfḅ³

TryItOnline!
Will work for any n, given enough memory, Jelly's base conversion is not restrictive.
How?
*`ḶbµQ⁼$Ðfḅ³ - Main link: n
    µ        - monadic chain separation
*            - exponentiation with
 `           - repeated argument, i.e. n^n
  Ḷ          - lowered range, i.e. [0,1,2,...,n^n-1]
   b         - covert to base n (vectorises)
        Ðf   - filter keep:
       $     -     last two links as a monad
     Q       -         unique elements
      ⁼      -         equals input (no vectorisation)
           ³ - first program argument (n)
          ḅ  - convert from base (vectorises)

JavaScript (ES7), 86 bytes
n=>{a=[];for(i=n**n;i--;j||a.unshift(i))for(j=i,b=0;(b^=f=1<<j%n)&f;j=j/n|0);return a}

Fails for 1 (Should output [0], but RangeErrors.)

Exactly what I had, but this would theoretically fail for 37 if precision weren't an issue, which I think makes it invalid...

@Artyer I've ported my Batch version, so now this will work for n from 1 to 13 before floating-point precision kills it.

I like how the solutions start off really short, and then suddenly jump an order of magnitude.

Batch, 204 200 bytes
@set/an=%1,m=1
@for /l %%i in (1,1,%1)do @set/am*=n
@for /l %%i in (0,1,%m%)do @set/ab=0,j=i=%%i&call:l
@exit/b
:l
@set/a"f&=b^=f=1<<j%%n,j/=n"
@if %f%==0 exit/b
@if %j% gtr 0 goto l
@echo %i%

Won't work for n > 9 because Batch only has 32-bit arithmetic. Conveniently, Batch evaluates f &= b ^= f = 1 << j % n as f = 1 << j % n, b = b ^ f, f = f & b rather than f = f & (b = b ^ (f = 1 << j % n)).

Mathematica, 59 48 bytes
Select[Range[#^#]-1,xMax[x~DigitCount~#]==1]&

Contains U+F4A1 "Private Use" character
Explanation
Range[#^#]-1

Generate {1, 2, ..., n^n}. Subtract 1. (yields {0, 1, ..., n^n - 1})
xMax[x~DigitCount~#]==1

A Boolean function: True if each digit occurs at most once in base n.
Select[ ... ]

From the list {0, 1, ..., n^n - 1}, select ones that give True when the above Boolean function is applied.
59 byte version
Select[Range[#^#]-1,xDuplicateFreeQ[x~IntegerDigits~#]]&

Perl 6, 47 bytes
{(0..$_**$_).grep: !*.polymod($_ xx*).repeated}

Returns a Seq. ( Seq is a basic Iterable wrapper for Iterators )
With an input of 16 it takes 20 seconds to calculate the 53905th element of the Seq (87887).
Expanded:
{       # bare block lambda with implicit parameter ｢$_｣

  ( 0 .. ($_ ** $_) )    # Range of values to be tested

  .grep:                 # return only those values

    !\                   # Where the following isn't true
    *\                   # the value
    .polymod( $_ xx * )  # when put into the base being tested
    .repeated            # has repeated values
  }
}

Mathematica, 48 55 bytes
Union[(x   x~FromDigits~#)/@Permutations[Range@#-1,#]]&

(The triple space between the xs needs to be replaced by the 3-byte character \uF4A1 to make the code work.)
Unnamed function of a single argument. Rather than testing integers for xenodromicity, it simply generates all possible permutations of subsets of the allowed digits (which automatically avoids repetition) and converts the corresponding integers to base 10. Each xenodrome is generated twice, both with and without a leading 0; Union removes the duplicates and sorts the list to boot.

Fails for 2. The function gives {0, 1}. I believe you need Permutations[Range@#-1, #] instead of Subsets[Range@#-1].

Gah, what a boneheaded mistake. Thank you for observing it, and for suggeting the perfect fix!

Vyxal, 14 13 bytes
ʁṖƛÞSƛṖ⁰vβ]fU

Try it Online!
ʁṖƛÞSƛṖ⁰vβ]fU
ʁ             # Range [0, n)
 Ṗƛ       ]   # For each permutation:
   ÞSƛ        # For each sublist in the permutation:
      Ṗ         # Generate the permutations of that
        v       # For each permutation:
         β        # Treating it as a list of digits, convert to base 10 from base
       ⁰          # <the input>
           f  # Flatten the resulting list
            U # Remove duplicates

;; can be ] (I think)

Vyxal, 7 bytes
eʁ'?τÞu

Try it Online!
 ʁ      # Range(0,
e       # n**n
  '     # Filtered by...
   ?τ   # Convert to base n
     Þu # All unique?

Haskell, 100 80 bytes
-20 bytes thanks to @Laikoni
f k=[n|n<-[0..k*k^k],let x#0=1>0;x#n|m<-mod n k=notElem m x&&(m:x)#div n k,[]#n]

Try it online!

90 bytes by dropping x from (#) and using a list comprehension for f: Try it online!

88 by merging (#) with the test function x: Try it online!

80 bytes by putting (#) into the list comprehension where k is given from context: Try it online!

Ruby, 73 bytes
->n,*a{i=-1
n>1?(0..n**n).filter_map{i+=1
d=i.digits(n)
i if d==d&d}:[0]}

Attempt This Online!

Japt, 14 bytes
o à cá mìU â ñ

Try it
Explanation:
o à cá mìU â ñ
o              # Get the range [0...input]
  à            # Find all arrays containing unique items from that range
    cá         # Find all orderings for each of those arrays
       m       # For each one:
         U     #  Treat it as an array of base-input digits
        ì      #  Convert it to a base-10 number
           â   # Remove duplicates
             ñ # Sort by ascending value

This alternative and this other alternative are longer, but seems like that strategy could become shorter if someone finds a better way to check for "contains no duplicate elements".

Japt, 13 10 bytes
pU ÇìU'âÃâ

Try it
pU ÇìU'âÃâ     :Implicit input of integer U
pU             :Raised to the power of itself
   Ç           :Map the range [0,U**U)
    ìU         :  Convert to base U digit array
      'â       :  Deduplicate and convert back to integer
        Ã      :End map
         â     :Deduplicate

05AB1E, 8 bytes
mÝʒIвDÙQ

Try it online or verify all test cases.†
Explanation:
m         # Push the (implicit) input to the power of the (implicit) input: nⁿ
 Ý        # Pop and push a list in the range [0,nⁿ]
  ʒ       # Filter this list by:
   Iв     #  Convert the integer to base-input as list
     DÙQ  #  Check if all items in this list are unique:
     D    #   Duplicate the list
      Ù   #   Uniquify the items in the copy
       Q  #   Check if the two lists are still the same
          # (after which the result is output implicitly)

† Note: input \$n=1\$ will output as [0,1] instead of [0]. This could be fixed in +1 byte by adding a ¨ after the Ý, to make the range \$[0,n^n)\$ instead. However, I'd argue for \$n=1\$ it should be allowed to output either [0] or [0,1]. If base-1 follows the same rules as the other bases, only 0 can be represented, making it practically useless. Because of that, bijective base-1 (aka unary) is usually used instead when someone talks about base-1, in which case:

\$n=0\$ as bijective base-1 will have an empty result (technically all unique)
\$n=1\$ as bijective base-1 results in a single tally mark (thus all unique)
\$n\geq2\$ as bijective base-1 results in \$n\$ amount of tally mark (thus not all unique)


text:
Evaluate the B-spline basis
B-splines are defined using a set of "knots", "control points", and degree. For the purposes of this challenge, the control points are not needed.
The knots are simply a list of strictly increasing real values (note that real B-splines may have repeated knots, for the purposes of this challenge assume knots are all unique). The degree is a non-negative integer.
The set of polynomial basis functions are recursively defined as (image credit):

where i is the i-th basis function, and p is the degree of the basis function. u is the curve parameterization, and u_j is the j'th knot.
The goal of this challenge is to evaluate all the basis functions for a curve of degree m at location u.
Input
Your program/function should take as input 3 parameters:

A real value for the location u
A non-negative integer for the curve degree m
A list of strictly increasing real values for the knots vector u_j

You may take these parameters in any order desired and may mutate the inputs as long as no additional information is added (for example, you may take the knots vector to be a combination of a real pointer and integer length).
The input may come from any source desired (stdio, function parameter, etc.).
You may assume the input describes a valid B-spline and that u is in the range of the knots vector.
Output
Your program/function should output a list of real numbers describing what the basis functions evaluate to. That is, you should output  for all 0 <= i <= n-1-m, where n is the number of knots (For 1-based indexing, then 1 <= i <= n - m). The output must be accurate to within 1% or 1000 ULP of the true value, whichever is greater. The output may be to any sink desired (stdout, return value, etc.)
Examples
All examples are formatted as such:
u
m
u_0 u_1 u_2 ...
N_{0,m}(u) N_{1,m}(u) N_{2,m}(u) ...

case 1:
.5
0
0 0.5 1
0 1

case 2:
.5
1
-1 0 1 2
0.5 0.5

case 3:
 0.9
 1
 -1 0 1 2 3
 0.1 0.9 0

case 4:
 1.1
 1
 -1 0 1 2 3
 0 0.9 0.1

case 7:
 3
 3
 -1 0 1 2 3 8 10 12 15 20
 0 0.5952381 0.38392857 0.02083333 0 0

Hints
Notice that N_{p} depends only on N_{p-1}. That means rather than recursing from the top-down, you could start at the base case and work up. While this is faster execution-wise, I'm not sure if this will necessarily produce the shortest code.
Here's a reference implementation using Python3+NumPy for the bottom-up approach:
from numpy import *

def basis(knots, m, u):
    # base case
    Ns = 1.*logical_and(knots[:-1] <= u, u < knots[1:])
    # work backwards, starting at the base case up to p=m
    for p in range(1,m+1):
        Ns = (u - knots[:-1-p]) * Ns[:-1] / (knots[p:-1] - knots[:-p-1]) \
             + (knots[p+1:] - u) * Ns[1:] / (knots[p+1:]- knots[1:-p])
    return Ns

Scoring
This is code golf; shortest answer in bytes wins. Standard loopholes are prohibited. You are welcome to use any built-ins desired.

It might be worth noting that the B-splines are equivalent to regular splines.

the use of u as both the parameter and as a knot variable was very confusing to me for a few minutes before I realized they were unrelated since I am completely knew to this stuff and have no clue what any of it actually does. Maybe consider using different variables for that? or is it standard in the literature?

also are the knots one or zero indexed?

What is k_0,k_1,... in your examples?

@flawr oops, that's a typo. Those are suppose to be the knots u_0, u_1, ...

@Maltysen I just copied the notation of Dr. Shene. It's not necessarily standard notation. I have the knots being zero-indexed, but I think the formulas still work when one-indexed (in that case, the basis functions would also be 1-indexed).

@helloworld922 I suggest swapping the non-descending with a strictly ascending, otherwise you could as well just remove all duplicates first to produce a meaningfull spline. (Results in the same as considering the division by 0 as 0). (Id consider this as unnecessary fluff)

@flawr oh interesting, I had no idea that was a property of B-splines! I always hated the duplicate knots corner cases in my own codes. I'll modify the question accordingly.

May we always take the input of u as a floating-point value even when it is supposed to be an integer?

@R.Kap do you mean m? u is already a real number. The actual type of m is not too important, so long as it can represent non-negative small integers.

@helloworld922 I mean even if u=1, can the input be taken as 1.0 instead of just 1? I'm asking because in Python 2, integer division is default and to activate float division, either the numerator or denominator must be a floating-point value.

oh, yes. That's fine.

Pyth - 83 82 bytes
Jesus, this is long, probably a few redundancies, but the formulas are long. This is a recursive solution that just implements the formulas given. The reference solution seems to be doing something else, but I don't know what. Maybe if I knew more about what all of this does...
KEM?H+.x*c-KJ@QG-@Q+GHJgGtHZ.x*c-=T@Qh+GHK-T@QhGghGtHZ&|>K@QGqK@QG<K@QhGgRvzt-lQvz

Test Suite.

Python 2, 192 185 bytes
D,E,Q=input();J=0;exec"F=lambda u,m,j,i:+(j[i]<=u<j[-~i])if m<1else(u-j[i])/(j[i+m]-j[i])*F(u,~-m,j,i)+(j[-~i+m]-u)/(j[-~i+m]-j[-~i])*F(u,~-m,j,-~i);print F(D,E,Q,J);J+=1;"*(~-len(Q)-E)

A direct implementation of the formula given with recursion in the lambda and iteration using exec. Prompts for input through the command line upon invocation as u,m,[u_0,u_1,u_2...] with u always input as a float (e.g. if u=1, then u would still be input as 1.0) and outputs each of the len([u_0,u_1,u_2...])-1-u values on a separate line.
Try it Online! (Ideone)