g | x | w | all
Bytes Lang Time Link
004Vyxal240812T023914Zemanresu
052Ruby221022T023559ZJordan
039Attache180503T031315ZConor O&
037Perl 6160602T035915ZBrad Gil
058Haskell160531T173707Znimi
030Perl 5180501T194620ZDom Hast
165Tcl160531T211246ZDút
090JavaScript Firefox 3057160531T225041ZNeil
nanPerl 5171212T215930ZXcali
055Wolfram Language Mathematica171212T125906ZMartin E
096Python3170221T170803ZBlocks
252C170218T130416ZAbel Tom
216C170218T145434ZMrPaulch
022Brachylog160531T144910ZFatalize
028Actually160602T063319Zuser4594
nanPyth160531T132650ZFryAmThe
069Python160601T054000ZRootTwo
060Julia160531T195305ZDennis
103JavaScript ES6160531T205417Zedc65
276Oracle SQL 11.2160531T183432ZJeto
071Python160531T172558ZDennis
006Jelly160531T150710ZDennis
242Hoon160531T150057ZRenderSe
01705AB1E160531T143917ZEmigna
013MATL160531T140505ZLuis Men

Vyxal, 4 bytes

NZΠU

Try it Online!

   U # Unique
  Π  # Combinations
N    # Of swapcased input
 Z   # and input

Ruby, 52 bytes

->s{a,*b=s.map{[_1,_1.swapcase]}
a.product(*b).uniq}

Attempt This Online!

Attache, 39 bytes

&Cross[Sum@V]##Unique@V#SwapCase=>Chars

Try it online!

Similar to the perl answer. (I've lost my more interesting alternative, I should be posting those in the next few hours.)

Perl 6, 37 bytes

{[X~] '',|.comb.map:{unique .lc,.uc}}

Try it

Explanation:

{
  [X[~]]                     # cross combine using &infix:<~> operator
    '',                      # empty string so that 1 character strings work
    |                        # flatten the following into outer list
      .comb                  # get every character from input string
      .map:                  # and map it with:
        { unique .lc, .uc }
}

Test:

#! /usr/bin/env perl6

use v6.c;
use Test;

my &case-permutation = {[X~] '',|.comb.map: {unique .lc,.uc}}

my @tests = (
  'a1a' => <a1a a1A A1a A1A>,
  'abc' => <abc abC aBc aBC Abc AbC ABc ABC>,
  'Hi!' => <hi! hI! Hi! HI!>,
  'ž1a' => <ž1a ž1A Ž1a Ž1A>,
);

plan +@tests;

for @tests -> $_ (:key($input),:value($expected)) {
  is case-permutation($input).sort, $expected.sort, .gist
}
1..4
ok 1 - a1a => (a1a a1A A1a A1A)
ok 2 - abc => (abc abC aBc aBC Abc AbC ABc ABC)
ok 3 - Hi! => (hi! hI! Hi! HI!)
ok 4 - ž1a => (ž1a ž1A Ž1a Ž1A)

Haskell, 69 58 bytes

import Data.Char
mapM(\x->toLower x:[toUpper x|isAlpha x])

Try it online!

Edit: @Angs saved 11 bytes. Thanks!

Perl 5, 30 bytes

s/\pl/{\l$&,\u$&}/g;say<"$_ ">

Try it online!

Outputs an additional space at the end of the output.

Tcl, 165 181 bytes

set n -1
while {[incr n]<1<<[llength [set s [split $argv {}]]]} {puts [join [lmap c $s b [split [format %0[llength $s]b $n] {}] {string to[expr $b?{u}:{l}] $c}] ""]}

Improvements thanks to sergiol. Previous answer:

set s [split $argv {}]
set n -1
while {[incr n]<1<<[llength $s]} {set r ""
foreach c $s b [split [format %0[llength $s]b $n] {}] {set r $r[string [expr $b?{tou}:{tol}] $c]}
puts $r}

Uses a binary number to choose between upper/lower case when creating the output text.

JavaScript (Firefox 30-57), 92 90 bytes

f=([c,...s])=>c?[for(t of f(s))for(d of new Set(c.toUpperCase()+c.toLowerCase()))d+t]:['']

Edit: Saved 2 bytes because new Set will happily extract the unique characters from a string.

Perl 5, 52 + 1 (-n) = 53 bytes

@k{glob s/./lc("{$&,").uc"$&}"/ger}++;say for keys%k

Try it online!

Wolfram Language (Mathematica), 55 bytes

""<>#&/@Union@Tuples[{#,ToUpperCase@#}]&@*Characters

Try it online!

is the transpose operator (and displays as a superscript T in Mathematica).

Python3, 96 bytes

i=input().lower()
for l in{*__import__('itertools').product(*zip(i,i.upper()))}:print(*l,sep='')

Late to the party but still had a go. Thanks to DLosc for reminding me of the stuff I missed, giving me golfing tips and saving me a bunch of bytes. :)

C 229 252 bytes

i,n,j,k,l;f(char *s){l=strlen(s);for(i=0;i<l;i++)s[i]=tolower(s[i]);int v[l];for(i=0;i<l;i++)v[i]=0;for(i=0;i<pow(2,l);i++){n=i,k=0;for(;n;k++){v[k]=n;n/=2;}for(j=0;j<l;j++){v[j]%=2;if(v[j])s[j]=toupper(s[j]);else s[j]=tolower(s[j]);}printf("%s ",s);}}

Ungolfed version:

void f(char *s)
{
  int i,num,k,l=strlen(s);
  for(i=0;i<l;i++)
     s[i]=tolower(s[i]);

   int v[l];
   for(i=0;i<l;i++) 
     v[i]=0;   

   for(i=0;i<pow(2,l);i++)
   {
      num=i,k=0;
      for(;num;k++)
      {
         v[k]=num;
         num/=2;        
      } 

      for(int j=0;j<l;j++)
      {
        v[j]%=2;

        if(v[j])
         s[j]=toupper(s[j]);
        else
         s[j]=tolower(s[j]);

      }
      printf("%s \n",s);       

   } 
}

Explanation:

Try it online!

C, 216 bytes

k,i,j,p,n,m;z(char *c){n=-1;m=0;while(c[++n])if(c[n]>64&c[n]<90)c[n]+=32;else if(c[n]<'a'|c[n]>'z')m++;k=1<<(n-m);for(j=0;j<k;j++){for(i=0;i<n;i++){p=1<<i;putc((j&p)==p?toupper(c[i]):c[i],stdout);}putc(0xa,stdout);}}

This is a different approach, the same approach as the other C answer.

Should I delete this, and put it under the other answer as a comment?

Let me explain with the Ungolfed version

k,i,j,p,n,m;
z(char * c) {
    int n=-1;       // We start at -1 because of forward incrementation
    int m=0;        // this will count the characters we don't have to manipulate
    while(c[++n])   // go until we reach '\0'
    {
        if(c[n]>='a'&c[n]<='z')c[n]-=32; // If we are lower case, then convert
        else if(c[n]<'A'|c[n]>'Z')m++;   // If we are neigther lower case
                                         // nor upper, then make a note
    }
   
    // get 2 ^ ("length" - "number of invonvertibles")
    k=1<<(n-m); 
    for(j=0;j<k;j++) {      // go through the combinations
        for(i=0;i<n;i++) {  // for each combination go though the characters
            p=1<<i;         // for each character get it's bit position
            putc(
                // if the bit position is set (==1) 
                (j&p)==p ?
                   tolower(c[i]) // convert
                   : c[i], // else: don't
                stdout);
        }
        putc(0xa, stdout);  // print a newline
    }
}

Brachylog, 25 22 bytes

:ef:1fd.
:2ac.
@u.|@l.

This works as well as the lowercase/uppercase predicates of Prolog, therefore it works on non-ASCII letters too:

?- run("ž1a",Z).
Z = ["Ž1A", "Ž1a", "ž1A", "ž1a"] .

Explanation

Unlike all other answers as of the moment I'm posting this, this does not use the cartesian product approach at all.

This is used to apply uppercasing or lowercasing on each char of the input, thus computing one possible permutation. Using findall on this predicate in the main predicate allows to compute all possible permutations (with some duplicates).

    :2a       Apply predicate 2 on the each element of the Input
       c.     Unify the Output with the concatenation of the elements of
              the previous list

This is used to turn a character of the string into either its uppercase or its lowercase version.

    @u.       Unify the Output with the uppercase version of the Input
       |      Or
        @l.   Unify the Output with the lowercase version of the input

Actually, 28 bytes

;╗l2r∙`"'Ö*£"£M╜@Z"iƒ"£MΣ`M╔

Try it online!

This program can handle non-ASCII characters, thanks to the magic of Python 3.

Explanation:

;╗l2r∙`"'Ö*£"£M╜@Z"iƒ"£MΣ`M╔
;╗                            save a copy of input to reg0
  l                           length of input
   2r                         [0,1]
     ∙                        Cartesian product with self (length of input) times
      `                  `M   map:
       "'Ö*£"£M                 push `Ö` (swapcase) if 1 else `` for each value in list
               ╜@Z              zip with input
                  "iƒ"£M        swap the case of those values
                        Σ       join string
                           ╔  unique elements

Pyth, 13 12 11

{msrVQd^U2l

1 byte thanks to Leaky Nun!

Another byte thanks to Jakube!

Try it here or run a Test Suite

We create a list of lists True/False values by taking the cartesian product of the list [0, 1] with itself a number of times equal to the length of the input string. So each of the sublists has the same length as the input string. Then we apply the r function as a vector operation over the input and the list, so we get r letter value for each sub element. r with second argument zero is to lowercase and with one it is to upper case. This creates duplicates on non-letters, which means we need to remove duplicates from the result.

Python, 69 bytes

import itertools as i;f=lambda s:set(i.product(*zip(s,s.swapcase())))

Julia, 66 60 bytes

!s=s>""?[~s[1:1]t for~=(ucfirst,lcfirst),t=!s[2:end]]∪[]:[s]

Try it online!

JavaScript (ES6), 103

Handles non-ASCII characters

(a,r=new Set)=>a?f(a.slice(1)).map(v=>(C=o=>r.add(a[0][`to${o}erCase`]()+v),C`Upp`,C`Low`))&&[...r]:[a]

Test

f=(a,r=new Set)=>a?f(a.slice(1)).map(v=>(C=o=>r.add(a[0][`to${o}erCase`]()+v),C`Upp`,C`Low`))&&[...r]:[a]

function test() { O.textContent = f(I.value).join('\n') }

test()
<input id=I oninput='test()' value='ž1a'>
<pre id=O></pre>

Oracle SQL 11.2, 276 bytes

WITH v AS(SELECT SUBSTR(:1,LEVEL,1)c,ROWNUM p FROM DUAL CONNECT BY LEVEL<=LENGTH(:1))SELECT w FROM(SELECT REPLACE(SYS_CONNECT_BY_PATH(c,','),',','')w FROM(SELECT UPPER(c)c,p FROM v UNION SELECT LOWER(c),p FROM v)START WITH p=1CONNECT BY PRIOR p=p-1)WHERE LENGTH(:1)=LENGTH(w);

Un-golfed

WITH v AS
( -- Split input into an array of characters 
  SELECT SUBSTR(:1,LEVEL,1)c,ROWNUM p FROM DUAL CONNECT BY LEVEL<=LENGTH(:1)
)
SELECT w 
FROM   ( -- Build every string combination
         SELECT REPLACE(SYS_CONNECT_BY_PATH(c,','),',','')w 
         FROM   ( -- Merge upper and lower arrays, keep same position for each character, it allows to mix cases
                  SELECT UPPER(c)c,p FROM v UNION SELECT LOWER(c),p FROM v
                )
         START WITH p=1          -- Start with first character (either lowercase or uppercase)
         CONNECT BY PRIOR p=p-1  -- Add the next character (either lowercase or uppercase)
       )
WHERE LENGTH(:1)=LENGTH(w); -- Keep only full strings

Ugly as hell, must be more golfable.

Python, 74 71 bytes

f=lambda s:s and{r[0]+t for r in{s,s.swapcase()}for t in f(s[1:])}or{s}

Handles non-ASCII characters. Test it on Ideone.

Jelly, 6 bytes

żŒsŒpQ

This is a monadic link (function) that expects a string as left argument and returns a list of strings.

Handles non-ASCII characters. Try it online!

How it works

żŒsŒpQ  Monadic link. Argument: s (string)

 Œs     Swapcase; change the case of all letters in s.
ż       Zipwith; pair each character with itself with changed case.
   Œp   Take the Cartesian product of all pairs.
     Q  Unique; deduplicate the Cartesian product.

Hoon, 242 bytes

|=
t/tape
=+
l=(reap (pow 2 (lent t)) t)
%+
roll
(gulf 0 (dec (lent l)))
|=
{a/@ b/(set tape)}
=+
%+
turn
(gulf 0 (dec (lent t)))
|=
n/@
=+
t=(snag n t)
=+
k=(trip t)
?:
=(0 (cut 0 n^1 a))
?:
=((cuss k) t)
(cass k)
(cuss k)
t
(~(put in b) -)

Ungolfed:

|=  t/tape
=+  l=(reap (pow 2 (lent t)) t)
%+  roll  (gulf 0 (dec (lent l)))
|=  {a/@ b/(set tape)}
    =+  %+  turn  (gulf 0 (dec (lent t)))
      |=  n/@
      =+  t=(snag n t)
      =+  k=(trip t)
      ?:  =(0 (cut 0 n^1 a))
        ?:  =((cuss k) t)
              (cass k)
        (cuss k)
      t
    (~(put in b) -)

I'm not sure how much smaller this could be, unfortunately.

First, we set l equal to a list with 2^(length t) repetitions of t. Hoon doesn't have a fac function in the stdlib, but 2^n is always bigger than n!, so we simply map over the bigger list and use a set (hashmap) to de-duplicate entries.

We then fold over the list [0..(length l)], accumulating into a (set tape). We need to do this instead of mapping over l directly because we also need to know what number repetition it is (a), but can't simply increment an accumulator due to Hoon being a pure language.

We map over [0..(length t)] (again so we have the current index), setting t to the nth character in the string, checking if the nth bye of a and inverting the case (cuss or cass, depending if it changes or not). The return type of this map is a tape.

We then put the string into our hashmap, and return the hashmap of all the strings.

05AB1E, 17 bytes

Code:

vyDš‚N0Êiâvy˜J})Ù

Explained:

vy                     # for each character in input
  Dš‚                  # create a pair of different case, eg: ['ž', 'Ž']
     N0Êiâ             # for all pairs but the first, take cartesian product
                         result will be a list of layered lists eg: [['ž', '1'], 'a'] 
            vy         # for each such list
              ˜J}      # deep flatten and join as a string eg: ž1a
                 )Ù    # wrap in array and remove duplicates

Try it online

MATL, 13 bytes

tYov!Z}N$Z*Xu

Try it online!

Explanation

t       % Implicit input string. Duplicate
Yo      % Change case of string
v       % Concatenate as a 2xN char array, where N is input length
!       % Transpose: Nx2 char array. Each row has different case, if letter
Z}      % Split into rows: gives N strings of 2 chars. Each char has different 
        % case if it's a letter, or is repeated otherwise
N$      % Specify N inputs for next function
Z*      % Cartesian product of the N strings. Each combination is a row.
        % Repeated chars (i.e. non-letters) give rise to duplicate rows.
Xu      % Remove duplicate rows. Implicit display