# Wave-Particle Duality Laterally Programmatically

Write a program or function that takes in a nonempty single-line string. The string will either be zero or more spaces followed by one period (a particle), such as . or          ., or the string will be a sequence of one or more alternating forward and back slashes (a wave) that could start with either one, such as \ or /\/ or \/\/\/\/\/\/.

In either case, propagate the particle/wave to the right by one unit.

Specifically, in the particle case, insert a space before the ., moving it one place to the right, then output the resulting string. For example:

. .
 .  .
  .   .
   .    .
    .     .
     .      .
      .       .
       .        .

In the wave case, append either / or \ appropriately so the wave keeps alternating and it's length increases by one, then output the resulting string. For example:

//\
\\/
/\/\/
\/\/\
/\//\/\
\/\\/\/
/\/\/\/\/
\/\/\/\/\

In either case, the output may not have trailing spaces but an optional trailing newline is allowed.

The shortest code in bytes wins.

• Comments are not for extended discussion; this conversation has been moved to chat. Aug 14, 2016 at 3:33

?}\.Q+dQ+Q-"\/"e

 i=>i.includes(".")?" "+i:i.charAt(i.length-1)=="/"?i+"\\":i+"/"