[Question]
  [
## The Challenge
Display the alphabet from a given letter read from console input. If the letter is uppercase, you have to display the alphabet uppercased. The alphabet printed must end in the precedent letter of the one inserted. If an additiontal parameter is added to the input (a simple dot `.`) the alphabet should be printed one letter in each line. Otherwise, the alphabet should be printed in the same line, separed by a simple space. If wrong input is send to the program it will not print anything.
Inputs examples:
Input:
```
c
```
Program's ouput:
```
d e f g h i j k l m n o p q r s t u v w x y z a b
```
Input
```
H.
```
Program's ouput:
```
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
E
F
G
```
  
[Answer]
## GolfScript ~~48 75 73 70 67 66 63 57~~ 53
```
(91,65>.+.{32+}%+.@?>(;25<''+.,1>*\['''.']?[' 'n 0]=*
```
Online demos:
* [Test case 1 ('c')](http://golfscript.apphb.com/?c=OydjJwooOTEsNjU%2BLisuezMyK30lKy5APz4oOzI1PCcnKy4sMT4qXFsnJycuJ10%2FWycgJ24gMF09Kg%3D%3D&run=true)
* [Test case 2 ('H.')](http://golfscript.apphb.com/?c=OydILicKKDkxLDY1Pi4rLnszMit9JSsuQD8%2BKDsyNTwnJysuLDE%2BKlxbJycnLiddP1snICduIDBdPSo%3D&run=true)
* [Test case 3 (invalid input)](http://golfscript.apphb.com/?c=OydAJwooOTEsNjU%2BLisuezMyK30lKy5APz4oOzI1PCcnKy4sMT4qXFsnJycuJ10%2FWycgJ24gMF09Kg%3D%3D&run=true)
### Update:
Now the last rule is also implemented. Thanks to [Ventero](https://codegolf.stackexchange.com/users/84/ventero) for pointing out the issue.
### Update:
I rewrote the code from scratch and found new ways to shorten it even further.
### History of modifications:
```
.,3<\(:x;:§['''.']?)and{91,65>.+.{32+}%+.x?).{>25<''+{§n' 'if}%}{;;}if}''if
.,3<\(:x;:§['''.']?)*{91,65>.+.{32+}%+.x?).{>25<''+{§n' 'if}%}{;;}if}''if
.,3<\(:x;:§['''.']?)*{91,65>.+.{32+}%+.x?).!!@@>25<''+{§n' 'if}%*}''if
.,3<\(:x;:§['''.']?)*!!91,65>.+.{32+}%+.x?).!!@@>25<''+{§n' 'if}%**
.,3<\(:x;:§['''.']?)*91,65>.+.{32+}%+.x?).@@>25<''+{§n' 'if}%@@*!!* 
.(@,3<@:§['''.']?)*91,65>.+.{32+}%+@1$?).@@>25<''+{§n' 'if}%@@*!!*
.(@,3<@:§['''.']?)*91,65>.+.{32+}%+@1$?):x>25<''+{§n' 'if}%\x*!!*
.(@,3<@:§['''.']?)*91,65>.+.{32+}%+@1$?):x>25<''+§n' 'if*\x*!!*
(\:§['''.']?)91,65>.+.{32+}%+@1$?):x>25<''+§n' 'if*\x*!!*
(91,65>.+.{32+}%+.@?>(;25<''+.,1>*\['''.']?[' 'n 0]=* 
```
[Answer]
## C, 135 129  128 chars
Damn, so many different magic numbers, but no way to get rid of them.
Has to be run with the input as program parameter. Now follows the "wrong input" requirement.
```
c;main(a,b)char**b;{if(a==2&&isalpha(**++b)&&!(c=1[*b])||c==46&&!2[*b])for(;++a<28;)printf("%c%c",**b-=**b+6&31?-1:25,c?10:32);}
```
Explanation:
```
c;                   // Variable that will be used later
main(a,b)char**b;{   // There's one parameter => a = 2, b[1] = the parameter
                     // Wrong input checks: We want...
  if(
     a==2 &&         // 1 parameter and ...
     isalpha(**++b)  // lower- or uppercase letter as parameter,
                     // increase b so we can access it better
     &&              // and ...
     !(c=1[*b]) ||   //   either no further character,
                     //     save the character in c, or...
     (c==46&&!2[*b]) //   a dot as next character and no further characters
    )                // if check succeeded, execute the for loop, else do nothing
  for(;++a<28;)      // This will loop 26 times (2..27)
    printf("%c%c",   // Print two characters
                     // First character to print:
      **b            // We'll print the first character of the parameter,
       -=            // but decrement it before printing
       **b+6&31?     // if the last five bits (31 = 11111b) are not 26 (6 == -26 mod 32)
        -1           //   decrement it by -1 (aka increment it)
        :25,         //   else (char=z/Z) decrement by 25, so we start over at a/A
                     // Second character to print:
      c?             // c is either ASCII 0 or a dot (ASCII 46)
       10            //   dot     -> print a newline
       :32);         //   ASCII 0 -> print a space (ASCII 32)
}
```
The `**b+6&31` part uses the fact that the ASCII codes for lowercase/uppercase character are the same if only looking at the last 5 bits and the remaining 5 bits are in range 1..26.
Version without "wrong input" requirement (82 chars):
```
main(a,b)char**b;{for(b++;++a<28;)printf("%c%c",**b-=**b+6&31?-1:25,1[*b]?10:32);}
```
[Answer]
### Ruby, 72 71 61 characters
```
gets;25.times{$><<$_=$_.succ[0]+=$1?$/:' '}if~/^[a-z](\.)?$/i
```
This ruby version uses a regular expression to verify the input. Fortunately, the Ruby string method [`succ`](http://ruby-doc.org/core-1.9.3/String.html#method-i-succ) does most of the work for us (including the wrap-around).
*Edit:* 61 characters with the help of [chron](https://codegolf.stackexchange.com/users/3856/chron) and [Ventero](https://codegolf.stackexchange.com/users/84/ventero).
[Answer]
# Ruby: ~~127~~ ~~113~~ 92 (?) characters
(I can't find the rule about the penalty score on using `-p`. Added 1 for now. If wrong, please correct me.)
```
$_=if ~/^([a-z])(\.)?$/i;s,e=$1>?Z?[?a,?z]:[?A,?Z];[*$1.succ..e,*s...$1]*($2==?.?$/:" ")end
```
Sample run:
```
bash-4.2$ ruby -pe '$_=if ~/^([a-z])(\.)?$/i;s,e=$1>?Z?[?a,?z]:[?A,?Z];[*$1.succ..e,*s...$1]*($2==?.?$/:" ")end' <<< c
d e f g h i j k l m n o p q r s t u v w x y z a b
bash-4.2$ ruby -pe '$_=if ~/^([a-z])(\.)?$/i;s,e=$1>?Z?[?a,?z]:[?A,?Z];[*$1.succ..e,*s...$1]*($2==?.?$/:" ")end' <<< H.
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
E
F
G
bash-4.2$ ruby -pe '$_=if ~/^([a-z])(\.)?$/i;s,e=$1>?Z?[?a,?z]:[?A,?Z];[*$1.succ..e,*s...$1]*($2==?.?$/:" ")end' <<< seven
```
[Answer]
# Ruby, ~~101~~ 95
```
i,d=gets.split''
[*?a..?z].join[/#{i}/i]
($'+$`).chars{|c|$><<(i>?Z?c:c.upcase)+(d==?.?$/:' ')}
```
[Try it online](http://ideone.com/v0ezQ)
[Answer]
### GolfScript, 80 72 Characters
```
.).46={;)}*25,{65+.32+}%?)\""=*!!\([{)..31&26-!26*-}25*;]n+\"."=n" "if**
```
Lots of the code is testing for valid input and the "print nothing"-option. The actual logic is 37 characters only.
[Test cases online](http://golfscript.apphb.com/?c=OydjJwouKS40Nj17Oyl9KjI1LHs2NSsuMzIrfSU%2FKVwiIj0qISFcKFt7KS4uMzEmMjYtITI2Ki19MjUqO11uK1wiLiI9biIgImlmKioKcHV0cwoKOydILicKLikuNDY9ezspfSoyNSx7NjUrLjMyK30lPylcIiI9KiEhXChbeykuLjMxJjI2LSEyNiotfTI1KjtdbitcIi4iPW4iICJpZioqCnB1dHMKCjsnQCcKLikuNDY9ezspfSoyNSx7NjUrLjMyK30lPylcIiI9KiEhXChbeykuLjMxJjI2LSEyNiotfTI1KjtdbitcIi4iPW4iICJpZioqCnB1dHMKCgoKCg%3D%3D)
[Answer]
## q/k4 66 64 63 60 58 56 + 2 penalty
penalty for global variable init, algorithm is 56 as below:
**56:**
```
if[&/x in".",l:(a;A)90>*x;1@/1_,/|_[0,l?x;l,'"  \n"@#x]]
```
**58:**
```
if[&/x in".",l:(a;A)90>*x;1@/(1_,/|_[0,l?x;l]),'"  \n"@#x]
```
* change from if-else to if allowed to reorganize code and get rid of ";" at the end
**60:**
```
1@/$[&/x in".",l:(a;A)90>*x;1_,/|_[0,l?x;l];" "],'"  \n"@#x;
```
* eventually got rid of this redundant check
**63:** 
```
1@/$[&/x in".",l:(a;A)90>*x;1_,/|_[0,l?x;l];" "],'" \n""."in x; 
```
* print chars recursively instead a whole object
* still can't get off identity comparsion *x in "."* in two places... :(
* semicolon at the end is required, otherwise print function (1@) would print it's return value to stdout.... damn
**64:** 
```
2@,/$[&/x in".",l:(a;A)90>*x;1_,/|_[0,l?x;l];" "],'" \n""."in x;  
```
**EDIT:**
Added penalty of 2 for global initialization(x:), same if wrapping function into brackets (as slackware suggested)  
not sure if changing namespace should be punished as well...then it's another 3 
```
(.Q`a`A) instead of (a;A)
```
Example:
```
q)\         - switch interpreter to k4
 \d .Q     - change to native namespace
  x:"c"
  if[&/x in".",l:(a;A)90>*x;1@/1_,/|_[0,l?x;l,'"  \n"@#x]]
d e f g h i j k l m n o p q r s t u v w x y z a b
  x:"@"
  if[&/x in".",l:(a;A)90>*x;1@/1_,/|_[0,l?x;l,'"  \n"@#x]]    
  x:"H."
  if[&/x in".",l:(a;A)90>*x;1@/1_,/|_[0,l?x;l,'"  \n"@#x]]
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
A
B
C
D
E
F
G
  x:...
```
[Answer]
## Perl, 131 127 117 112 106 104 102 98 96 92 91 90 93 71 66 65 64 58 characters
```
s!^([a-z])(\.?)$!print chop,$2?$/:$"for($1..az)[1..25]!ie
```
Usage:
```
perl -ne 's!^([a-z])(\.?)$!print chop,$2?$/:$"for($1..az)[1..25]!ie'
```
One character has been added to the count for the `n` option.
Largest cut was only possible because of seeing the behaviour of `++` on characters in [Jon Purdy's answer](https://codegolf.stackexchange.com/a/7049/737).
[Answer]
## Perl, 149, 167
### Update
* Added sanity check.
* Took ardnew suggestion about the separator application.
```
exit if $ARGV[0] !~ /[a-z]\.?/i;    # sanity check input
($x,$d)=split //,$ARGV[0];          # split input arguments
@l=65..90;                          # define uc letter range
push @l,splice @l,0,ord(uc $x)-64;  # rotate letter range
pop @l;                             # remove the argument letter
print join $d?$/:$",                # print the joined list
  map {ord($x)>90?lc chr:chr} @l;   # map chr and lc as appropriate
```
[Answer]
## Python, 83
```
r=raw_input()
i=ord(r[0])
exec"i+=1-26*(i%%32>25);print chr(i)%s;"%","["."in r:]*26
```
[Answer]
## PHP, ~~120~~ ~~119~~ 113
```
<?$v=fgets(STDIN);$f=$c=$v[0];ctype_alpha($c++)||die;for(;$c[0]!=$f;$c=$c[0],$c++)echo$c[0],$v[1]=='.'?"\n":" ";
```
[Answer]
# Mathematica 158 159 204 199 183 167 165 162
**Code**
```
f@h_ := Most@RotateLeft[#, Position[#, h][[1, 1]]] &[FromCharacterCode /@ 
        (65~Range~90 + 32 Boole@LowerCaseQ@h)];
g = Characters@# /. {{p_} :> Row[f@p, " "], {p_, "."} :> Column@f@p, _ -> ""} &
```
**Usage**
```
g["c"]
g["H"]
g["H."]
g["seven"]
```
![usage](https://i.stack.imgur.com/GHpBN.png)
[Answer]
# J 43
```
|:1j1#(25{.(u:,2#65 97+/i.26)(>:@i.}.[)])"0
```
## Examples:
```
|:1j1#(25{.(u:,2#65 97+/i.26)(>:@i.}.[)])"0 's'
```
t u v w x y z a b c d e f g h i j k l m n o p q r 
```
|:1j1#(25{.(u:,2#65 97+/i.26)(>:@i.}.[)])"0 's.'
```
t  
u  
v  
w  
x  
y  
z  
a  
b  
c  
d  
e  
f  
g  
h  
i  
j  
k  
l  
m  
n  
o  
p  
q  
r 
```
|:1j1#(25{.(u:,2#65 97+/i.26)(>:@i.}.[)])"0 '['
```
This solution evolved on the J programming forum: <http://jsoftware.com/pipermail/programming/2012-August/029072.html>
Authors: AlvordBossCerovskiCyrEllerHuiLambertMcCormickMillerQuintanaSchottSherlockTaylorTherriault
## Explanation
J phrases are executed starting on the right, passing the on-going result to the left as it gets evaluated. Since it's interactive, we can look at pieces of the solution in isolation to better understand them.
The middle part generates the upper and lower case alphabet in Unicode:
```
   u:,2#65 97+/i.26
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
```
The " u: " verb converts its numeric right argument to Unicode characters. The numeric argument is generated from the ASCII values for the upper- and lower-case characters by adding the numbers for "A" and "a" each to the values from 0 to 25 generated by "i.26":
```
   65 97+/i.26
65 66 67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
```
The right-hand portion, 
```
   ((>:@i.}.[)])"0
```
looks up ( i. ) the position of the right argument ( ] ) in the left ( [ ) - which is the vector of letters above - and drops ( }. ) one more ( >: ) than that number. The ' "0 ' applies this phrase to 0-dimensional (scalar) arguments.
```
   ('123H999' (>:@i.}.[)])"0 'H'
999
```
The " 25 {. " phrase takes the first 25 elements of the vector on the right.
The penultimate phrase " 1j1 # " on the left replicates its right argument according the number on the left. A simple number does a simple replication:
```
   2 # 'ABCD'
AABBCCDD
```
However, a complex number - indicated by the " j " between the real and imaginary portions - inserts a fill element according to the imaginary part. Here we indicate one fill element by the one to the right of the " j ".
```
   2j1 # 'ABCD'
AA BB CC DD 
```
As with most J primitives, the replicate verb ( # ) works on numeric arrays in an analagous fashion to how it works on character arrays. As shown here,
```
   1j1 # 1 2 3
1 0 2 0 3 0
```
we see that the default numeric fill element is zero whereas for characters it is the space character.
Finally, the leftmost token " |: " transposes the result of the preceding verbs to its right.
Explanation provided by Devon McCormick. Thank you Devon.
[Answer]
# brainfuck, 303
```
,>,>++++++[-<-------->]<++[[-]+++++[->++++<]>++<]>++++++++++<<[->+>>>+<<<<]>>>>>>+++++++++++++++[-<++++++<<++++++>>>]<[<[->>]>[>>]<<-]<[[-]++++++++[-<++++>]]<<<[->>>+>+<<<<]>>>>>+[[-]<.<<<.>[->>>+>+<<<<]>>>[-<<<+>>>]<[->+>-<<]>[-<+>]+>[-<[-]>]<[++++[-<----->]<->]<+[->+>+<<]<[->+>-<<]>[-<+>]>>[-<<+>>]<]
```
Currently it doesn't support the `If wrong input is send to the program it will not print anything` part, and it can probably be shorter. I plan on fixing it later. Right now my brain is too \*\*\*\*ed to continue.
[Answer]
## C, 110
Sometimes prints "spaces" between letters, sometimes not. 
```
i,j;main(int c,char*l){gets(l);l[1]&=10;j=*l%32;c=*l&~31;for(i=j;i<j+25;i++){l[0]=c+i%26+1;printf("%2s",l);}}
```
Slighly more readable:
```
i,j;
main(int c,char*l)
{
  gets(l);
  l[1]&=10;          // makes . to line feed and some other chars to "start of text" 
                     // which looks like space in some cases 
                     // (the byte can become either 0, 2, 8 or 10)
  j=*l%32;           // 0b 000c cccc, these five bits code which letter was chosen
  c=*l&~31;          // 0b ccc0 0000, these three bits code upper/lowercase
                     // 0b ccc0 0000 + (0b 000c cccc + [0..24])%26 + 1
  for(i=j;i<j+25;i++){l[0]=c+i%26+1;printf("%2s",l);}
}
```
Runs:
```
$ ./a.out
G
 H I J K L M N O P Q R S T U V W X Y Z A B C D E F
$ ./a.out
p.
q
r
s
t
u
v
w
x
y
z
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
```
[Answer]
# JavaScript, 137
Unfortunately a bit verbose (`String.fromCharCode` and `charCodeAt`).
```
for(x=b=(n=prompt(m={122:97,90:65})).charCodeAt(r='');/^[a-z]\.?$/i.test(n)&&(x=m[x]||x+1)!=b;)r+=String.fromCharCode(x)+(n[1]?"\n":" ");
```
[Answer]
# Perl, ~~77~~ ~~76~~ ~~70~~ 68
```
chomp(($a,$b)=split//,<>);$"=$/if$b;map{++$a=~/(.)$/}1..25;print"@a"
```
Edits:
1. Saved a character using regex instead of `substr`.
2. Saved 6 characters using `map` instead of `for`.
3. Saved 2 characters by omitting final newline.
[Answer]
## R, 219
Ugly, long... still works.
```
f=function(l){if(!nchar(l)%in%c(1,2))invisible()else{s=ifelse(nchar(l)==1," ","\n");l=substr(l,1,1);v=letters;if(l%in%v){}else v=LETTERS;l=grep(l,v);if(l==26)cat(v[1:25],sep=s)else cat(c(v[l+1:(26-l)],v[1:l-1]),sep=s)}}
```
Usage:
```
f("a")
f("c.")
f("H")
f("z")
f("Z.")
f("seven")
```
[Answer]
## C, 146 chars *(terrible)*
```
main(){char b[100];gets(b);for(char a=b[0],c=a,d=a&223,e=b[1];++c!=a&64<d&d<91&(!e|e==46&!b[2]);(c&31)>26?(c&=96):(putchar(c),putchar(e?10:32)));}
```
I'm not very experienced in C, which probably shows... >.< I had a feeling that chars being integers would be helpful, but it didn't actually seem to make as big of an impact as I hoped... I'll leave my attempt here though, feel free to suggest improvements.
Unminified version:
```
main() {
  char b[999]; // assume that the line will fit in 999 chars...
  gets(b);
  // a is the char we start on, c is the char that we iterate,
  // d is toUppercase(a), e is just an alias for the second char.
  for (char a = b[0], c = a, d = a&223, e=b[1];
      // increment c, make sure that we haven't reached a yet.
      // also check the other conditions (first char is letter, second char
      // is either '.' or NULL, third char is NULL if second char was '.').
      ++c != a & 64 < d & d < 91 & (!e | e == 46 & !b[2]);
      (c&31) > 26     // check if we need to wrap around
        ? (c &= 96)   // if so, wrap
        : (putchar(c), putchar(e?10:32))  // otherwise, print char & separator
  );
}
```
[Answer]
## VBA 225
Formatted to run from the immediate window:
```
s=InputBox(""):n=Asc(Left(s,1)):l=Len(s):p=IIf(l<3,IIf(l=2,IIf(Right(s,1)=".",vbCr,"")," "),""):c=IIf(n>64 And n<91,65,IIf(n>96 And n<123,97,99)):o=n-c+1:If o>0 And p<>"" Then For i=o To o+24:x=x & Chr(i Mod 26+c) & p:Next:?x
```
Broken down into individual lines (needs to be surrounded by `Sub` block and needs a different `print` method to work in a module, thus making the code longer):
```
s=InputBox("")
n=Asc(Left(s,1))
l=Len(s)
p=IIf(l<3,IIf(l=2,IIf(Right(s,1)=".",vbCr,"")," "),"")    
c=IIf(n>64 And n<91,65,IIf(n>96 And n<123,97,99))
o=n-c+1
If o>0 And p<>"" Then 
For i=o To o+24
x=x & Chr(i Mod 26+c) & p
Next
End If 'Not needed when completed in single line format
MsgBox x
```
[Answer]
# Java 8, 127 bytes
```
a->{String r="",d=a.length>1?"\n":" ";char c=a[0],C=c;for(;++c<(c<97?91:123);r+=c+d);for(c=C<97?64:'`';++c<C;r+=c+d);return r;}
```
**Explanation:**
[Try it online.](https://tio.run/##dY9Bb8IwDIXv/AorFxIVqnWbNtEQ0NTLLuOyY1dpnhugrKQoTZEQ6m/v0lLttEn2wX7P1vcOeMZ5ddLmkH93VGJdwxsW5joBKIzTdoukYdOPAO/OFmYHxGmPNs0AhfT71rev2qErCDZgQEGH89V1tFvF2CxXGJba7Nx@Fa3Zh2ExAyb7P0AK07tsliiS28pyGQS05LRcPK8XURzdPwhpA0VBLgaZVNJLT4/x9HM6eJNf3WrXWANWtp28QZ2ar9JDjWznqsjh6NPxG1qaoRiTXWqnj2HVuPDkFVcabkLijFjoqsRTvliLFy7EkPh//2v450E7absf)
```
a->{                        // Method with character-array parameter and String return-type
  String r="",              //  Result-String, starting empty
         d=a.length>1?      //  If the length of the input is larger than 1
            "\n"            //   Set the delimiter to a new-line
           :                //  Else:
            " ";            //   Set the delimiter to a space
  char c=a[0],              //  Get the input letter
       C=c;                 //  And create a copy of it
  for(;++c<(c<97?91:123);   //  Loop from this letter + 1 to (and including) 'Z'/'z'
    r+=c+d);                //   And append the result with a letter + the delimiter
  for(c=C<97?64:'`';++c<C;  //  Loop again from 'A'/'a' to (and excluding) the input-letter
    r+=c+d);                //   And append the result with a letter + the delimiter
  return r;}                //  Return the result
```
[Answer]
## **Mumps, 91, 86, 82,79,76**
```
r t i t?1A.1"." s a=$A(t),p=a>90*32+65 f i=1:1:25 w *(a+i-p#26+p) w:t["." !
```
Not such a modern language ;) I'm sure there's a bit of optimization space left..
Explanation:
```
r t 
```
read input
```
i t?1A.1"."
```
check if t matches the required input
```
s a=$A(t),p=a>90*32+65 f i=1:1:25 { w *(a+i-p#26+p) w:t["." !}
```
basic for loop through the alphabet. Note that mumps is strictly evaluating left to right. True=1, so you get 65 or 97 as a result for p, # is the modulo operator
tests:
```
USER>d ^golf
d.e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
a
b
c
USER>d ^golf
tuvwxyzabcdefghijklmnopqrs
USER>d ^golf
h.i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
a
b
c
d
e
f
g
USER>d ^golf
hallo
USER>
```
(you'll need a mumps runtime env, ie Caché to run this this)
edit: bold heading
edit: had a wrong solution, fixed now. Thanks to rtfs and Averroees for pointing this out
[Answer]
**JavaScript: 141**
```
c="",b=c[0].charCodeAt()<91,a="abcdefghijklmnopqrstuvwxyz",b&&(a=a.toUpperCase()),a=a.split(c[0]),a=a[1]+a[0],a=c[1]?a.split("").join("\n"):a
```
Commented version:
```
c="", //write input here (examples "a", "B", "c.", "D.")
b=c[0].charCodeAt()<91, //true for upperC, false for lowerC
a="abcdefghijklmnopqrstuvwxyz", //the abc
b&&(a=a.toUpperCase()), //if upper, turn main string to upperC
a=a.split(c[0]), //split by the first char of input
a=a[1]+a[0], //swap the two parts
a=c[1]?a.split("").join("\n"):a //if input second char, add breaklines in between
//the output is inside 'a'
```
[jsFiddle DEMO](http://jsfiddle.net/mdvJg/1/)
[Answer]
Here is my first attempt at it with APL.
```
⍞{1 1≡(2⌈⍴⍺)⍴⍺∊'.',⍵:⊃(~=/2⍴⍺)⌷(,X,' ')(X←25 1⍴1↓(X⍳⊃⍺)⌽X←(⎕A∊⍨⊃⍺)⌷2 26⍴⍵)}6↓26⌽⎕UCS 65+⍳58
```
if I can use a single global variable `A←2 26⍴6↓26⌽⎕UCS 65+⍳58` then I can shorten the above down to the following:
```
{1 1≡(2⌈⍴⍵)⍴⍵∊'.',,A:⊃(~=/2⍴⍵)⌷(,X,' ')(X←25 1⍴1↓(X⍳⊃⍵)⌽X←(⎕A∊⍨⊃⍵)⌷A)}⍞
```
[Answer]
C++11
```
#include <iostream>
#include <vector>
#include <cstdio>
int main(int argc, const char * argv[])
{
    std::vector<char> list1,list2;
    for( char c = 'a'; c <='z'; c++ )
    {
        list1.push_back( c );
        list2.push_back( toupper( c ) );
    }
    char c = getchar();
    auto f = [ c ]( std::vector<char> list )
    {
        auto i = std::find( list.begin(), list.end(), c );
        if( i == list.end() )
            return;
        auto c = i;
        for( ;; )
        {
            c++;
            if( c == list.end() ) c = list.begin();
            if( c == i )break;
            std::cout<<*c<<"\n";
        }
    };
    f( list1 );f(list2);
    return 0;
}
```
[Answer]
C (111)
```
main(int i, char**c){if(isalpha(*c[1]))for(i=0;i<25;i++) printf("%c",isalpha((*c[1])+1)?++*c[1]:(*c[1]-=25));}
```
---
## dissection
```
if(isalpha(*c[1])) // start with char-check.
for(i=0;i<25;i++) // we need 25 values, excluding input char. reusing i.
printf("%c", // print char. ofcourse.
isalpha((*c[1])+1) ? ++*c[1] : (*c[1]-=25)); 
//check if we are past z/Z and fall back to a/A. 
//make that available to print. 
```
---
Works]$ ./test 5 
Works]$ ./test W 
XYZABCDEFGHIJKLMNOPQRSTUV 
Works]$ ./test M NOPQRSTUVWXYZABCDEFGHIJKL 
Works]$ ./test g hijklmnopqrstuvwxyzabcdef 
Works]$ ./test [ 
Works]$ ./test a bcdefghijklmnopqrstuvwxyz
Works]$ ./test Z
ABCDEFGHIJKLMNOPQRSTUVWXY
---
Thank you for some food for thought.
[Answer]
## Perl, 226 characters
```
die "Invalid input " if $ARGV[0] !~ /[a-z]\.?/i;
@listA=(a...z);
$index=ord(lc(substr($ARGV[0],0,1)))-97;
print join(substr($ARGV[0],1) ? "\n" : " ",map{$ARGV[0] =~ /[A-Z]/?uc $_:$_}(@listA[$index+1...25],@listA[0...$index]));
```
[Answer]
**C# 170**
```
using System.Linq;namespace N{class P{static void Main(string[]a){foreach(char e in"abcdefghijklmnopqrstuvwxyz".ToCharArray().Where(o =>o>'c'))System.Console.Write(e);}}}
```
Uncompressed
```
using System.Linq;
namespace N {
    class P {
        static void Main(string[]a){
            foreach (char e in "abcdefghijklmnopqrstuvwxyz".ToCharArray().Where(o => o > 'c'))
                System.Console.Write(e);
        }
    }
}
```
[Answer]
# C, 117
```
main(c,s,d){d=c=getchar(),s=getchar();for(s=s<0?32:s^46?0:10;d+=d+6&31?1:-25,s&&isalpha(c)&&d^c;printf("%c%c",d,s));}
```
Credit to schnaader for the d+6&31 trick.
<http://ideone.com/ts1Gs9>
[Answer]
# Bash: 110 bytes
```
(([[ $1 =~ [a-z] ]]&&echo {a..z})||([[ $1 =~ [A-Z] ]]&&echo {A..Z}))|([ "${1:1:1}" = . ]&&sed 's/ /\n/g'||cat)
```
In terms of explanation, it's pretty straightforward, no magic tricks - this is just something that bash is intrinsically well suited for. In terms of the non-obvious bits:
* `{a..z}` is a very underused trick in bash - it expands to `a b c d...`. You can do the same to generate numerical sequences.
* Bash can do regex matching, `[[ $1 =~ [a-z] ]]` runs a regex match against the first program argument for characters from a to z. Likewise for A-Z. You need double square brackets for it though, `[` can't do it.
* `${1:1:1}` gets a substring of $1 (the first argument), one character in, one character long - that is, it returns the second character of the string, what we expect to be `.`.
* `sed 's/ /\n/g'` simple regex: searches and replaces spaces with newlines. If `.` is the second character of the string, we pipe input to this, or otherwise...
* `cat` is the final trick here - if we don't want to replace spaces with newlines, we feed stdin to cat instead which simply outputs it again.
]