text:
Tips for golfing in Pike
Pike is a dynamically typed interpreted scripting language, heavily influenced by C, which typically compiles to C99 with a few #defines. (It even has a preprocessor!)
What general tips do you have for golfing in Pike? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Pike (e.g. "remove comments" is not an answer).

Array operators.
Pike's arrays have some operators that act ... weird.

({1})+({2}) returns ({1,2}) (concatenation)
({1,3,8,3,2}) - ({3,1}) returns ({8,2}) (the former argument without elements in the latter argument)
({1,3,7,9,11,12}) & ({4,11,8,9,1}) will return: ({1,9,11}) (intersection)
({1,2,3}) | ({1,3,5}) will return ({1,2,3,5}) (union)
({1,3,5,6}) ^ ({4,5,6,7}) will return ({1,3,4,7}) (symmetric difference)
({1,2,3,4,5})/({2,3}) will return ({ ({1}), ({4,5}) }) (split at occurences)
({1,2,3,4})/2 will return ({ ({1,2}), ({3,4}) }) (split by length, truncates the excess.)
({1,2,3,4,5})/2.0 will return ({ ({1,2}), ({3,4}), ({5}) }) (split by length, keeps the excess.)
({1,2,3,4,5})%3 will return ({4,5}) (excess of split by length).

Abuse mixed.
Pike is unfortunately not exactly identical to C; for instance the type of a list of strings is array(string), not char[][] or even string[].
Any time you need a type declarator and it's not int, mixed (the "any" type, which gets promoted to the actual type of the RHS at runtime) is liable to be shorter.
A function that takes a list of ints and sorts it, then returns it, for a whopping 41 bytes:
array(int)s(array(int)l){return sort(l);}

Or, the type-inferencing version, which is 31 bytes:
mixed s(mixed l){return sort(l);}

My answer to Manage Trash So uses a lot of mixed.


text:
Pascal's Triangle as a 2-dimensional list
Create a Pascal's Triangle that is a nested list and contains zeros in the unused spots.
In the output array, the numbers of Pascal's Triangle are separated by zeroes and padded by zeroes on each side so that they are centered. For example, the bottom row (last sub-array) must have no zeroes on the left and the right; the second-last sub-array has one zero padding on each side, and so on.
Here is the output for input 5:
[[0,0,0,0,1,0,0,0,0],
[0,0,0,1,0,1,0,0,0],
[0,0,1,0,2,0,1,0,0],
[0,1,0,3,0,3,0,1,0],
[1,0,4,0,6,0,4,0,1]]

As usual, the solution with the fewest bytes wins.

Well, there are the extra zeros.

This program prints the one you want (Python 3):print("def pascal(n):\n #make the nested list\n a=[[0 for i in range(2*n+1)] for j in range(n+1)] #make the list\n a[0][n]=1 #add the initial 1\n for i in range(1,n+1):\n  for j in range(2*n+1):\n   a[i][j]=a[i-1][j-1]+a[i-1][(j+1)%(2*n+1)] #the main part\n return a")

@CatsAreFluffy The extra zeroes just replace the spaces in the previous iteration - this is functionally the exact same problem.

Can I use the native array representation syntax for my language, or is the format non-negotiable?

Jelly, 13 bytes
Nr=0ṙ-,1S$³Ð¡

Try it online!
Explanation
Nr                 Get the range [-n -n+1 ... 0 ... n-1 n].
  =0                Logical NOT the entire range: [0 0 ... 1 ... 0 0].
         $³Ð¡       Repeat n times, and cumulate the results:
    ṙ-,1                Rotate by both -1 and 1
        S               Sum the results.

this seems to give no output

@Razetime I guess that -5R was [-5, -4, ... 5] in some super-old version of Jelly, but now it's the empty list. I'll fix it, but probably a modern Jelly answer could be way shorter.

How do you learn to write jelly? I've been trying but Im struggling to do basic stuff since it works so much differently from "normal" languages (C, C#, python, etc). Normally I teach myself by googling stuff, but It seems like there is no help online beyond what's in the github repo

The logical not is really clever

You can join the jelly hypertraining chatroom for help with your programs: https://chat.stackexchange.com/rooms/57815/jelly-hypertraining Some people are also willing to give a beginner friendly tutorial

Maybe the Jelly builtins have changed since you posted this 8 years ago, but you're currently outputting the result for n+1 instead of n.

BQN, 20 17 bytes
-3 bytes thanks to/inspired by ovs
{(«+»)⍟0=1↓∾˜}↕

Anonymous function that takes an integer and returns a list of lists. Run it online!

Being able to use the Repeat operator with an Array argument is very neat! (not possible in APL) {(«+»)⍟¬×1↓∾}⟜↕ saves two bytes

Ah, nice (and the ⟜ isn't necessary, either). Still wish there were a good way to write the whole thing tacitly.

Mathematica, 70 68 bytes
NestList[ListConvolve[{1,0,1},#,2]&,Join[#,{1},#],#2]&[0~Table~#,#]&

Similar to the MATL solution.

Mathematica, 48 bytes
CellularAutomaton[{#+#3&@@#&,{},1},{{1},0},#-1]&

CellularAutomation is fantastic.

Javascript, 152 146 bytes
f=i=>[...Array(i)].map((x,j)=>(z=[...Array(i*2-1)].map((_,k)=>+!!~[i-j,i+j].indexOf(k+1)),y=j?z.map((_,k)=>_||(k&&(k+1 in y)?y[k-1]+y[k+1]:_)):z))

f=i=>[...Array(i)].map(
    (x,j)=>(
        z=[...Array(i*2-1)].map(
            (_,k)=>
                +!!~[i-j,i+j]
                    .indexOf(k+1)
        ),
        y=j?z.map(
            (_,k)=>_||
                (k&&(k+1 in y)?
                    y[k-1]+y[k+1]
                :_)
        ):z
    )
)

F=i=>JSON.stringify(f(+i)).replace(/],|^.|.(?=.$)/g,'$&\n')
I.oninput()
<input id=I onInput="O.innerHTML=F(I.value)" value=5><pre id=O>

Haskell, 66 bytes
q n|d<-0<$[2..n]=scanl(\(s:t)_->zipWith(+)(0:s:t)$t++[0])(d++1:d)d

Usage example: q 4 -> [[0,0,0,1,0,0,0],[0,0,1,0,1,0,0],[0,1,0,2,0,1,0],[1,0,3,0,3,0,1]].
How it works:
d <- 0<$[2..n]                      -- bind d to a list of (length n)-1 zeros
scanl                               -- build a list
                         (d++1:d)   -- starting with  [d ++ 1 ++ d]
      \(s:t)_                    d  -- by combining the previous element with the
                                    -- elements of d, but ignoring them, i.e.
                                    -- build a list of (length d) by repeatedly
                                    -- modifying the start element by
          zipWith(+)                -- adding element-wise
                    (0:s:t)         -- the previous element prepended by 0
                           t++[0]   -- and the tail of the previous element
                                    -- followed by a 0

Seriously, 33 bytes
╩╜r`╣;lD0nkdZΣ`M╜rRZ`i0nkd@;)kΣ`M

Try it online
I'm relatively certain at least 7 or so of those bytes can be shaved off, so I'm going to wait to post an explanation until I'm done golfing this further.

MATL, 24 22 21 bytes
tEq:=Gq:"t5BX+8L)]N$v

EDIT (May 20, 2016): as of version 18.0.0 of the language, the above code needs a few changes to run. The link below includes those modifications
Try it online!
This uses a loop to push each new row onto the stack. A new row is computed from the previous row applying convolution with [1,0,1] and keeping only the desired size. After the loop, all rows are concatenated into a 2D array, which is displayed. 2D array are displayed in MATL as column-aligned numeric tables.
t           % implicit input n. Duplicate
Eq          % 2*n-1
:           % range [1,2,...,2*n-1]
=           % gives [0,0,...1,...0,0]. This is the first row
Gq:         % range [1,2,...,n-1]
"           % for each. Repeat n-1 times
  t         %   duplicate latest row. This duplicate will become the next row
  5B        %   push array [1,0,1] (5 converted to binary)
  X+        %   convolution
  8L        %   predefined literal [2,-1i]. Used for indexing
  )         %   apply that index: remove one element at each end
]           % end for each
N$v         % concatenate all rows into a 2D array. Implicitly display

Python 3, 172 158 133 bytes
def p(n):
 x=2*n+1;y=range
 a=[[0]*x]*n;a[0][n]=1
 for i in y(1,n+1):
  for j in y(x):a[i][j]=a[i-1][j-1]+a[i-1][(j+1)%(x)]
 return a

Keeps getting better

this isn't fully golfed yet, right?

Um, yeah. This (in a slightly less golfed form) is printed by a program I left a a comment on the question.

PHP, 106 bytes
for(;$r++<$a=$argn;)for($c=-$a;++$c<$a;)$t[$r][$c]=$r>1|$c?$t[$r-1][$c-1]+$t[$r-1][$c+1]?:0:1;print_r($t);

Try it online!

Pari/GP, 44 bytes
n->[Vecrev((x+1/x)^i*x^n,2*n+1)|i<-[0..n--]]

Try it online!

Brachylog, 27 26 bytes
~l{h1&jb}≜!{ẉ&h0&⟨↺z↻⟩+ᵐ↰}

Outputs N lists, separated by newlines. Try it online!
Explanation
This was harder than I expected. :P
~l{h1&jb}≜!{ẉ&h0&⟨↺z↻⟩+ᵐ↰}
~l                          Create a list whose length equals the input
  {     }                   Apply this predicate to it:
   h1                         The first element of the list is 1
     &                        and the list
      j                       concatenated to itself
       b                      with the first element removed
                              is the output of this predicate
                            Based on the order in which Brachylog tries possibilities,
                            the first list that satisfies these criteria will be
                            a list of N-1 zeros, a one, and N-1 more zeros
         ≜                  Instantiate that list
          !                 Cut: prevents backtracking past this point
           {             }  Apply this recursive predicate:
            ẉ                 Write the list with a newline
             &                and
              h0              The first element of the list must be 0
                &             and
                 ⟨↺           Take the list rotated left one place
                    ↻⟩        and the list rotated right one place
                   z          and zip them together
                      +ᵐ      Sum each of the resulting pairs
                              This generates the next row from the current
                              row, failing once the nonzero numbers reach the edge
                              of the list
                        ↰     Call the predicate again with this new list as input

Pascal, 235 B
A submission in Pascal may not be amiss.
This function requires a processor supporting features of Extended Pascal as laid out by ISO standard 10206, in particular initial value specifiers (value) and schema data types.
type Z=integer;M(w,h:Z)=array[1..w,1..h]of Z
value[otherwise[otherwise 0]];p=^M;function f(n:Z)=r:p;var x,y:Z;begin
new(r,n*2-1,n);r^[n,1]:=1;for y:=2 to n do for x:=1 to r^.w do
r^[x,y]:=r^[x-1+ord(x<2),y-1]+r^[x+1-ord(x=r^.w),y-1]end

Antigolfed:
type
    { `Integer…` prefix for dictionary sorting with documentation tools. }
    integerPositive = 1‥maxInt;
    { The `value [otherwise [otherwise 0]]` ensures that
      all variables of this data type are initialized with zeros. }
    integerMatrix(
            width, height: integerPositive
        ) = array[1‥width, 1‥height] of integer
        value [otherwise [otherwise 0]];
    { Pointers can accommodate all discriminated types. }
    integerMatrixReference = ↑integerMatrix;

{ Functions cannot return variably‑sized data, therefore we need a pointer. }
function pascal(protected n: integerPositive) = result: integerMatrixReference;
    var
        { `For`‑loop counter variables have to be _proper_ variables.
          It is not possible to simply re‑use `n` or an `array` element. }
        x, y: integerPositive;
    begin
        new(result, n × 2 − 1, n);
        result↑[n, 1] ≔ 1;
        { Build lines from top to bottom. }
        for y ≔ 2 to n do
        begin
            { Fill lines from left to right. }
            for x ≔ 1 to result↑.width do
            begin
                { The member right above the current member is
                  the neutral element of addition, in other words zero. }
                result↑[x, y] ≔ result↑[pred(x) + ord(x < 2), pred(y)] +
                    result↑[succ(x) − ord(x ≥ result↑.width), pred(y)]
            end
        end
    end

05AB1E, 13 bytes
Lαû_IGÐÁsÀ+})

Port of @Lynn's Jelly answer.
Try it online.
If outputting each inner list on a separated newline is allowed, it could be 1 byte less instead:
Lαû_IF=DÁsÀ+

Try it online.
Explanation:
L          # Push a list in the range [1, (implicit) input]
 α         # Take the absolute difference of each with the input: [input-1,input-2,...,1,0]
  û        # Palindromize it
   _       # Check for each inner value whether it's equal to 0 (0s with 1 in the center)
    IG     # Loop the input-1 amount of times:
      Ð    #  Triplicate the current list
       Á   #  Pop the top, and rotate it once towards the right
      s    #  Swap so another copy is at the top
       À   #  Pop and rotate it once towards the left instead
        +  #  Add the values in the two rotates lists together
     })    # After the loop: wrap all lists on the stack into a list
           # (after which this matrix is output implicitly as result)

    IF     # Loop the input amount of times:
      =    #  Print the current list with trailing newline (without popping)
       D   #  Duplicate the list
           # (nothing is implicitly printed, since we've already printed explicitly prior)

MathGolf, 14 bytes
(_╤m┬\ô_‼╫╪m+]

Port of @Lynn's Jelly answer.
Try it online.
If outputting the inner lists concatted is allowed, the trailing ] could be omitted:
Try it online.
If outputting the result for \$n+1\$ instead of \$n\$ is allowed, the leading (_ can be omitted:
Try it online.
Explanation:
(          # Decrease the (implicit) input-integer by 1
 _         # Duplicate this input-1
  ╤        # Push a list in the range [-n-1,n-1]: [-n-1,-n,-n+1,...,-1,0,1,...,n-2,n-1]
   m       # Map over each inner integer:
    ┬      #  Check whether it equals 0 (1 if 0; 0 otherwise)
 \         # Swap so the duplicated input-1 is at the top
  ô        # Loop that many times, with 6 characters as inner code-block:
   _       #  Duplicate the current list
    ‼      #  Apply the next two builtins separately on the current list at the top of
           #  the stack:
     ╫     #   Rotate once towards the left
     ╪     #   Rotate once towards the right
      m+   #  Add the values at the same positions in the lists together
        ]  # After the loop: wrap all lists on the stack into a list
           # (after which the entire stack is output implicitly as result)

source: Stack Exchange

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

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

sort: votes


text:
Does the water ultimately reach the tank?
In the ASCII art world, there is water, hash walls and letter mechanisms.
You are in a room made up of hash walls (# signs):
#######
#     #
#     #
#     #
# ### #
#     #
#######

You install an S water source (S sign) and an E water tank (E sign) which can receive water from any direction, but you only have one S source and one E tank.
#######
#  S  #
#     #
#     #
# ### #
#  E  #
#######

So you have to select wisely where to place the source. That's where you pull off your code-golf skills.
The task
You get an input consisting of a string representing a room with the source and the tank:
#######
#  S  #
#     #
#     #
# ### #
#  E  #
#######

You have to find out if the water ultimately reaches the tank. The water flows down, if possible, else to the left and right, if possible. The water doesn't accumulate because it doesn't go up.
So, for the above input, the result is:
#######
#  *  #
#  *  #
#*****#
#*###*#
#**O**#
#######

The water happily reaches the tank, so you must output a truthy value.
But if the water doesn't reach the tank:
#######
#S    #
#     #
#  E  #
# ### #
#     #
#######

#######
#*    #
#*    #
#* X  #
#*### #
#*****#
#######

Then you must output a falsy value.
Write a program to decide whether the water ultimately reaches the tank. Your code should be as short as possible.
Assumptions

Assume that the input is always valid (the entire room is an enclosed rectangular region with the S and E).
Assume there is only one room provided as input.

Test Cases
Your program should return a truthy value for the following test cases:
#######
#  S  #
#     #
#     #
# ### #
#  E  #
#######

#######
#  S  #
#     #
#  E  #
#     #
#     #
#######

#######
#     #
#     #
# SE  #
# ### #
#     #
#######

###############################################
#                      S                      #
#                                             #
#                                             #
#                                             #
#               ###############               #
#                                             #
#  ##################     ##################  #
#                                             #
#                                             #
#                    #####                    #
#                      E                      #
###############################################

#######
#  S  #
#     #
#     #
# ### #
#   # #
### ###
## E ##
#     #
#######

But a falsy value for the following test cases:
#######
#S    #
#     #
#  E  #
# ### #
#     #
#######

#######
#     #
# SE  #
#     #
#     #
#     #
#######

#######
#     #
#  E  #
#     #
#  S  #
#     #
#######

####################################
#                                  #
#                                  #
#                                  #
#S             #                  E#
####################################

The second to last room in the True category and the last room in the False category were shamelessly stolen borrowed from Koth: Jump and Run by Manu (who deleted the sandbox post).
The last room in the True category is from Martin Buttner's answer in Retina.

Note: I deleted my KOTH sandbox post, your challenge looks much better :)

Does'nt the water accumulated until it fill any room? Thus the water always reach the tank if and only if they are in the same room.

@Bob no, the water doesn't accumulate. It doesn't go up. Also, there is only one room provided as input.

Pro tip for formatting test cases in true/false challenges (or classification challenges with few classes): group the test cases by output and separate the groups so you can avoid the from /to/really bits (which makes it easier for participants to process all test cases at once).

I'll incrementally move the green tick to golfier submissions as they win against the reigning accepted answer.

Note that while using that way, I still encourage more answers into the question. The accepting of an answer is not the end of the challenge.

So basically Minecraft liquid flow logic. Although in Minecraft I think the 3rd in your true test cases would return false since the water would only go towards the left side.

But the tank is not a solid block. It is a block which receives water from every direction.

Reminds me of falling-sand water physics.

Are there any restrictions as to how the input should be taken in?  Strings, array...?

The whole input is a string.

I wonder how much longer the code would be to show the flow of the water so you can see where it all ends up

Snails, 20 bytes
\S{d(=\#n)?^#},!(t\E

Prints 0 for the falsey value and 1 for the truthy value.
Try it online!

\S matches S at the start
d sets direction to down
{...}, matches the stuff in braces 0 or more times
=\# is an assertion which succeeds if there is a # char ahead of the snail, but does not move it
n turns 90 degrees in either direction
(...)? matches the pattern in parentheses 0 or 1 times
\  matches a space and moves the snail onto it
!(... is a negative assertion
t teleports to any unmatched square in the grid
\E matches E

I don't want to compile this language by myself. Is there an online interpreter for this?

@zyabin101 No, there is no online interpreter.

Okay, time to call Dennis. :P Where is my projector?

http://i.imgur.com/dvWrAwP.png I made it myself.

Well, I've tried, but it's printing 0 for all test cases but one for me. What am I doing wrong?

@feersum Is there a play-by-play feature where the results of each command are output?

"=\#: Match succeeds if there is a wall ahead of the snail, but without moving it." It looks like this assertion fails.

The program is fixed now.

Slip, 20 + 2 = 22 bytes
S>( ^4|^4(?|`#)^T)*E

So Slip's still as broken as ever, but for once this was a challenge it could actually do. It was never really designed to be that golfy though, so it'll never beat Snails at anything :P
Needs the r flag (no repeating cells) to terminate.
Try it online. Output is the path taken for truthy, empty for falsy.
S                 Match S
>                 Rotate pointer downward
(                 Either...
 <space>^4          Match a space and point downwards
 |                  or
 ^4                 Point downwards
 (?|`#)             Match # below then reset pointer
 ^T                 Either turn left or right
)*                ... 0+ times
E                 Match E

Retina, 87 bytes
Byte count assumes ISO 8859-1 encoding.
+mT`E `S`(?<=^(?(1)!)(?<-1>.)*S.*¶(.)*)[E ]|.?S(?=(.)*¶.*#(?<-2>.)*(?(2)!)$)[E ]?
M`E
0

Try it online!
As much as 2D string processing is possible in Retina (or .NET regex in general), it's not exactly concise...
Explanation
+mT`E `S`(?<=^(?(1)!)(?<-1>.)*S.*¶(.)*)[E ]|.?S(?=(.)*¶.*#(?<-2>.)*(?(2)!)$)[E ]?

This is a flood-fill which marks all the cells that are reached by water with S. It does so by matching the characters that can be reached and then transliterating them to S with T-mode. This flood-fill goes through both spaces and E. The + at the beginning repeats this until the output stops changing.
As for the actual regex is contains two separate cases:
(?<=^(?(1)!)(?<-1>.)*S.*¶(.)*)[E ]

This matches a space or E which is exactly one cell below an S. The vertical matching is done by counting the prefix on the current line using balancing groups so we can ensure that the horizontal position is the same. This one takes care of falling water.
.?S(?=(.)*¶.*#(?<-2>.)*(?(2)!)$)[E ]?

This is very similar: it matches an S and if available the character before and after it, provided that the character directly beneath the S is a #. This takes care of water spreading along the ground.
When we're done it's very easy to determine if the water reached E. If it did, then E has been removed from the string in the flood-fill, and if not the E is still there. So let's count the number of Es:
M`E

But now that's 0 (which I'd consider falsy) for truthy test cases and 1 (which I'd consider truthy) for falsy test cases. We can invert this very easily by counting the number of 0s in this result:
0

Done.

Adding your input as a test case.

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


text:
Write a Chat Ping Counter
Your task is to write a program, that given a list of chat messages, count how many times each person gets pinged, so I can know how popular everyone is.  But, since I have to do it surreptitiously, I need it to be as small as possible so I can hide the code.
Specs

The input comes in a list of 2-tuples, with each item being of the form ("username", "message").
A ping to another user is defined as an @ followed by 3 or more letters that unambiguously refers to that user.
However, you also have to consider replies, which have to start with :messageid followed by a space.
Assume the first message has id 0 and proceed sequentially.
Output each user and say how many times each one got pinged.
The output can be in any order/reasonable format.
This is code-golf, so shortest code in bytes wins!

Test Cases
[["AlexA.", "I am wrong"], ["Quartatoes", "@Alex you are very wrong"], ["AlexA.", ":1 I am only slightly wrong"]]
AlexA.: 1
Quartatoes: 1

[["Doorknob", "I have never eaten an avocad."], ["AquaTart", ":0 I will ship you an avocad"], ["AlexA.", ":0 this is shocking"]]
Doorknob: 2
AquaTart: 0
AlexA.: 0

[["Geobits", "I like causing sadness through downvotes."], ["Flawr", "I want to put random message ids in my chat messages :0 askjdaskdj"]]
Geobits: 0
Flawr: 0

[["Downgoat", "goatigfs.com/goatgif"], ["Downotherthing", "@Downgoat cool gifs"], ["Dennis", "@Down cool gifs this is an ambiguous ping"]]
Downgoat: 1
Downotherthing: 0
Dennis: 0

I like how :0 doubles as a surprised emoticon.

"I like causing sadness through downvotes." You know there's only one proper way I can respond to that, right? ;)

Can there be multiple pings in each message? If so, can they be of different "types" (reply and one or more pings)? And if so, could you add some test cases involving this?

@Doorknob yes to all of these questions, I will add cases.

@Maltysen Can the username contain spaces? And would username message\nusername message be a valid way to take input?

At what point are we stopping with the "Alex is wrong" jokes?

Can replies contain mentions e.g. :0 @someone?

Can I take the input as an array of objects, such as [{user: "name", msg: "words"}, {...}]?

Can a reply be out of range (e.g. first message starting with :3) or a ping not satisfying any user in the room (e.g. @zzz)?

The final example seems invalid - @Down does not unambiguously refer to any user.

@isaacg That's the idea. Per the 2nd spec, they should only count towards a user if it referes to them unambiguously. Because @Down could refer to two people, it should be ignored.

@Mwr247 I get it - I thought that that spec meant that such ambiguous pings couldn't appear in the input, by rereading things I see that you're right.

Can a pinged user not yet have posted a message when he's pinged? e.g. is [["Doorknob","@Alex is wrong"],["Alex","I am only slightly wrong"]] valid input?

JavaScript (ES6), 245 210 bytes
a=>(p={},a.map(b=>p[b[0]]=0),(a.map(b=>b[1].match(/@[a-z]{3,}|^:\d+/gi)||[]).map(c=>c.map(d=>(z=(d[0]=='@'?(y=Object.keys(p).filter(e=>e.startsWith(d.slice(1)))).length<2?y:0:a[d.slice(1)[0]]))&&p[z[0]]++))),p)

Uses an object to create a unique list of names alongside pings. Then it looks through the messages for matches to either ping condition. If a name, it looks through the list of names to find if there is only one match, and then increments. If a reply, it simply references that index in the message array and pulls the name to be incremented. Finally, it returns the object.

Surely using an object is shorter. If it isn't I don't think you need to return the Map as an array

@Downgoat But Map is more fun right? Na, I originally overestimated how much extra it would take to reference an object, thinking I would have to a separate array for names, but you're right that it is much shorter this way.

PHP, 227 Bytes
foreach($_GET[a]as $c){$r[]=&$n[$c[0]]??$n[$c[0]]=0;preg_match("#^(:(\d+)|@(\w+))#",$c[1],$m);$m[2]==""?!$m[3]?:count($a=preg_grep("#^{$m[3]}#",array_keys($n)))>1?:$n[end($a)]++:$r[$m[2]]++;}foreach(($n)as$k=>$v)echo"$k: $v\n";


text:
Symbolic Differentiation of Composed Functions
Symbolic Differentiation 2: Back on the Chain Gang
Task
Write a program that takes in a certain sort of function from stdin and differentiates it with respect to x, using the chain rule.* The input function will be a string of the following form:
"trig_1 trig_2 trig_3 ... x"

where trig_n is a trigonometric function sin or cos, and there are at most four functions in the term. The example string
"cos sin sin x"

represents the function cos(sin(sin(x))).
Your output must take the following form:
k(trig_1 trig_2 x)(trig_a trig_b trig_c x)(trig_m trig_n x) et cetera

where k is a constant and parentheses represent groups to be multiplied together.
*The chain rule states that D[f(g(x))] = f'(g(x)) * g'(x)
Examples
"sin sin sin sin x" ==> 1(cos x)(cos sin x)(cos sin sin x)(cos sin sin sin x)
"cos x" ==> -1(sin x)
"cos sin x" ==> -1(cos x)(sin sin x)

Scoring
Your score is the length of your program in bytes, multiplied by three if you use a built-in or a library that does symbolic algebra.
Similar Challenges
The previous installment: polynomial differentiation
Polynomial integration
General differentiation

(Maybe [trigonometry] is an inappropriate tag?)

This is less of a [tag:calculus] question. It's more like a [tag:parsing] challenge than anything.

Java 8, 224 214 bytes
Let the games begin!
interface B{static void main(String[]a){String o="";int v=2,z=a.length-1,i=z,k;for(;i>0;o+="x)"){if(a[--i].equals("cos")){o+="(sin ";v=(v+2)%4;}else o+="(cos ";for(k=i;++k<z;)o+=a[k]+" ";}System.out.print(v-1+o);}}

This could (theoretically) extend infinitely.
Output for sin cos sin sin cos sin cos sin sin sin cos sin sin cos sin cos cos cos sin x:
1(cos x)(sin sin x)(sin cos sin x)(sin cos cos sin x)(cos cos cos cos sin x)(sin sin cos cos cos sin x)(cos cos sin cos cos cos sin x)(cos sin cos sin cos cos cos sin x)(sin sin sin cos sin cos cos cos sin x)(cos cos sin sin cos sin cos cos cos sin x)(cos sin cos sin sin cos sin cos cos cos sin x)(cos sin sin cos sin sin cos sin cos cos cos sin x)(sin sin sin sin cos sin sin cos sin cos cos cos sin x)(cos cos sin sin sin cos sin sin cos sin cos cos cos sin x)(sin sin cos sin sin sin cos sin sin cos sin cos cos cos sin x)(cos cos sin cos sin sin sin cos sin sin cos sin cos cos cos sin x)(cos sin cos sin cos sin sin sin cos sin sin cos sin cos cos cos sin x)(sin sin sin cos sin cos sin sin sin cos sin sin cos sin cos cos cos sin x)(cos cos sin sin cos sin cos sin sin sin cos sin sin cos sin cos cos cos sin x)

sed, 88 + 1 = 123 89 bytes
+1 for the -r (extended regex) flag.
s/^/d/
:
s/d(-?)sin (.*)/(\1cos \2)d\2/
s/d(-?)cos (.*)/(\1-sin \2)d\2/
s/--//
s/dx/1/
t

Explanation
Note: A single d is used as short version of d/dx in the golfed program.
First, preceed the string with d/dx. Then, reapeat the following replacements until the string does not change anymore:
d/dx sin ...    => (cos ...)d/dx ...
d/dx cos ...    => (-sin ...)d/dx ...
d/dx -sin ...   => (-cos ...)d/dx ...
d/dx -cos ...   => (sin ...)d/dx ...
d/dx x          => 1

Edit: The positive and negative cases are now handled within a single regex. This requires an additional search and replace to drop a double minus and is less elegant, but way shorter.

Elegant solution!

Mathematica, 115 bytes
ToExpression["d["<>StringReplace[#,{" "->"@"}]<>"]"]//.d[x_[y__]]->d[x][y]d[y]/.{d[sin]->cos,d[cos]->-sin,d[x]->1}&


text:
The Unholy numbers
This challenged is highly inspired by what @Mego created with his Holy and Holier numbers, lots of thanks to him and his puns.
Holy numbers are numbers composed of only the digits with holes, which are:
04689

Numbers with at least one unholy digit are considered unholy. Unholy digits are evil by definition, but being close to holy digits help them become neutral. Hence, the closer they are, the less unholy (1 when adjacent).
The unholiness of a number is the sum of the unholyness of its digits, a number composed of only unholy number has an infinite unholiness.
Number            :8 5 5 8 7
Digital Unholiness:0+1+1+0+1
Total Unholiness  :3

Number            :0 1 7 5 5 2 8 5 7
Digital Unholiness:0+1+2+3+2+1+0+1+2
Total Unholiness  :12

Number            :1 5 7 3 2 1
Digital Unholiness:∞+∞+∞+∞+∞+∞
Total Unholiness  :∞

Number            :0 4 6 8 9
Digital Unholiness:0+0+0+0+0
Total Unholiness  :0

Your task
You have to write a program or function that takes a positive integer or a string only composed of digits as input, and output its unholiness. If you chose to use an integer as input, you can assume it will never have a leading 0 as your language may drop it.
In case of infinite unholiness, you can chose between three outputs

The character ∞ (3 bytes)
Infinite output containing at least 1 non-zero digit, but only digits.
A built-in Infinity value.

This is code-golf, so the shortest code in byte wins, good luck!

Is returning a built-in Infinity value legal?

@Neil I will allow it, as I didn't even think of it, good point there.

Some of your example inputs start with a leading zero; is it intended that we can write our function with input "a positive integer" only if our language of choice won't automatically drop the leading zero? Many languages will be forced to take string input for this reason.

@ASimmons That's why I modified (a while back) the input so it can be a "string only composed of digits" aswell. Also, the important point isn't that it is a 0 but a holy digit, I will modify the post according to allow answer based on non-leading 0 numbers.

@katenkyo Yeah I saw you could input as a string but it seemed hard to take it as an integer. I approve of your edit to the OP.

MATL, 25 24 bytes
7Zq1hVmt~f!wf-|X<st~?xYY

Try it online!
Input is a string. In the output, infinity is natively displayed as Inf.
Explanation
7         % number literal
Zq        % prime numbers up to a 7: [2 3 5 7]
1         % number literal
h         % horizontal concatenation
V         % convert numbers to string: '2  3  5  7  1'
m         % take input implicitly. Determine which digits are 1,2,3,5,7
t         % duplicate
~         % element-wise negate: which digits are 4,6,8,9,0
f         % indices of occurrences of digits 4,6,8,9,0
!         % transpose into column array
w         % swap elements in stack
f         % indices of occurrences of digits 1,2,3,5,7
-         % element-wise subtraction with broadcast. Gives 2D array
|         % element-wise absolute value
X<        % minimum of each column
s         % sum of elements of array
t         % duplicate
~         % element-wise negate
?         % if all elements are true
  x       %   delete
  YY      %   push infinity
          % (implicit) end if
          % (implicit) convert to string and display

GNU APL, 27 bytes
{+/⌊/|(⍳⍴⍵)∘.-(⍵⍳⍕⍟788)~⍴⍵}

Try it online!
To try it out using the above link, IO must be set to 0 and the input is provided as a string. For example:
⎕IO←0
{+/⌊/|(⍳⍴⍵)∘.-(⍵⍳⍕⍟788)~⍴⍵}'017552857'

Explanation
{+/⌊/|(⍳⍴⍵)∘.-(⍵⍳⍕⍟788)~⍴⍵}  ⍝ Note: below explanation uses as example input 017552857
{                            ⍝ dfn
                  ⍟788       ⍝ computes natural log of 788, which happens to be 6.66949809, containing only (and all) holy digits
                 ⍕           ⍝ Converts this number to a string
               ⍵⍳            ⍝ Finds the indexes of chars in the right argument ⍵ which are present in the computed decimal. Items not found map to the length of the list, e.g. '017552857'⍳'6.66949809' -> 9 9 9 9 9 9 9 6 0 9
                      ~⍴⍵    ⍝ Removed all non-found indexes from the list 9 9 9 9 9 9 9 6 0 9 -> 6 0
      (⍳⍴⍵)                  ⍝ List of ascending integers up the length of the argument ⍵: 0 1 2 3 4 5 6 7 8
           ∘.-               ⍝ Inner product of the ascending integers 0..8 minus the match indexes 6 0. Result is ¯6 0, ¯5 1, .., 2 8
     |                       ⍝ Absolute value of all elements
   ⌊/                        ⍝ Take the minimum of each pair to get the closest distance to a Holy number 0 1 2 3 2 1 0 1 2
 +/                          ⍝ Sum this list

The reason for choosing GNU APL is that handily it will return the internal representation of infinity, '∞', when calculating the minimum value of the empty list. Summing this still retains ∞, which is then returned.
⍟788 was a cheeky way to lose a byte. I ended up writing a program to brute force inputs to functions until I found a suitable result which contained only holy numbers. Brute force program below:
    (,(⍳99)∘.{∧/(~'12357'∊c),'04689'∊(c←⍕b←⍺÷⍵):(⍺,'f',⍵,'=',b,'|') ⋄ 0}⍳99)~0

In this case it sees if any values of ⍺÷⍵ in 0 < ⍺,⍵ < 100 meet the condition. I manually played around with the functions to test.
It's a bit of a shame that this challenge doesn't allow undefined behaviour for the infinity case or that Dyalog doesn't return an infinite data type instead of throwing an error, otherwise the following solution would work in Dyalog APL:
APL (Dyalog Unicode), 23 bytes
{+/⌊/|(⍳⍴⍵)∘.-⍸⍵∊⍕⍟788}

Try it online!

Python (3), 137 131 bytes
def f(s):
 l=range(len(s))
 r=[min(i)for i in zip(*[[abs(j-i)for j in l]for i in l if s[i]in'46890'])]
 return sum(r)if r else'∞'

Results
>>> [f(i) for i in ['85587', '012321857', '157321', '04689']]
[3, 12, '∞', 0]

I get a count of 131 Bytes, Is there something I am missing? Also, great answer :).

@Katenkyo I always forgot my editor add en empty line at the end of the file

Ruby (2.7+), 69 63 chars, 71 65 bytes
->n{x=!r=l=0;n.map{'04689'[_1]?x=l=0*r-=l*l/4:r+=l+=1};x ?r:?∞}

Unsupported by TIO
Ruby (other), 71 65 chars, 73 67 bytes
->n{x=!r=l=0;n.map{|c|'04689'[c]?x=l=0*r-=l*l/4:r+=l+=1};x ?r:?∞}

Try it online!
How it works:

Iterate through the digits
If a digit is holy
reset increment
subtract a number* from the score to correct the overcounting
If a digit is unholy
add 1 to increment
add increment to score

*turns out this number depends only on the current value of the increment (l in the code), it's OEIS A002620 (quarter squares) (l*l/4 in the code).
Returns the ∞ character in case of infinity.
Interesting trick: x=l=0*r-=l*l/4 is equivalent to (r-=l*l/4;x=l=0) but using * instead of ; makes it a single statement allowing () to be dropped.
Edit: changed input type, now takes a list of characters.

Pyth, 31 29 27 25 bytes
smhS.e?}b"04689"akd.n4zUz

Try it online: Demonstration or Test Suite
For each digit I compute the distances to each number. A distance is infinty, if the second digit is not holy. From these lists I take the minimal distance and sum it up.
Explanation:
smhS.e?}b"04689"akd.n4zUz  implicit: z = input string of numbers
 m                     Uz  map each d in [0, 1, ..., len(z)-1] to:
    .e                z      map each k (index), b (value) of b to:
                akd            absolute difference between k and d

      ?}b"04689"               if b in "04689" else
                   .n4         infinity
   S                           sort
  h                            take the first element (=minimum)
s                              print the sum

JavaScript (ES6), 93 bytes
s=>[...s].map(n=>/[12357]/.test(n)?++u:u=0,u=1/0).reverse().map(n=>r+=n?n<++u?n:u:u=0,r=0)&&r

If Infinity isn't a legal infinity, then add 13 bytes for ==1/0?'∞':r.

05AB1E, 20 bytes
ŽāĀISåƶZĀiāδαø€ßOë'∞

Try it online or verify all test cases.
Explanation:
ŽāĀ                # Push compressed integer 40689
   IS              # Push the input-string, converted to a list of digits
                   #  i.e. "085281755283" → [0,8,5,2,8,1,7,5,5,2,8,3]
     å             # Check for each digit if it's in 40689 (1 if truthy; 0 if falsey)
                   #  → [1,1,0,0,1,0,0,0,0,0,1,0]
      ƶ            # Multiply each value by its 1-based index
                   #  → [1,2,0,0,5,0,0,0,0,0,11,0]
       Z           # Push the maximum of this list (without popping)
                   #  → 11
        Āi         # If this maximum is not 0 (so there are holy digits present):
                   #   → 1 (truthy)
          ā        #  Push a list in the range [1, list-length] (without popping the list)
                   #   → [1,2,3,4,5,6,7,8,9,10,11,12]
           δ       #  Apply double-vectorized:
            α      #   Take the absolute difference between each value
                   #    → [[0,1,2,3,4,5,6,7,8,9,10,11],[1,0,1,2,3,4,5,6,7,8,9,10],
                   #       [1,2,3,4,5,6,7,8,9,10,11,12],[1,2,3,4,5,6,7,8,9,10,11,12],
                   #       [4,3,2,1,0,1,2,3,4,5,6,7],[1,2,3,4,5,6,7,8,9,10,11,12],
                   #       [1,2,3,4,5,6,7,8,9,10,11,12],[1,2,3,4,5,6,7,8,9,10,11,12],
                   #       [1,2,3,4,5,6,7,8,9,10,11,12],[1,2,3,4,5,6,7,8,9,10,11,12],
                   #       [10,9,8,7,6,5,4,3,2,1,0,1],[1,2,3,4,5,6,7,8,9,10,11,12]]
             ø     #  Then zip/transpose the list of lists; swapping rows/columns
                   #   → [[0,1,1,1,4,1,1,1,1,1,10,1],[1,0,2,2,3,2,2,2,2,2,9,2],
                   #      [2,1,3,3,2,3,3,3,3,3,8,3],[3,2,4,4,1,4,4,4,4,4,7,4],
                   #      [4,3,5,5,0,5,5,5,5,5,6,5],[5,4,6,6,1,6,6,6,6,6,5,6],
                   #      [6,5,7,7,2,7,7,7,7,7,4,7],[7,6,8,8,3,8,8,8,8,8,3,8],
                   #      [8,7,9,9,4,9,9,9,9,9,2,9],[9,8,10,10,5,10,10,10,10,10,1,10],
                   #      [10,9,11,11,6,11,11,11,11,11,0,11],[11,10,12,12,7,12,12,12,12,12,1,12]]
              €ß   #  Get the minimum of each inner list
                   #   → [0,0,1,1,0,1,2,3,2,1,0,1]
                O  #  And sum everything together
                   #   → 12
         ë         # Else (no holy digits are present)
          '∞      '#  Push string "∞" instead
                   # (after which the top of the stack is output implicitly as result)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why ŽāĀ is 40689.

Jelly, 18 17 bytes
Dµ+ỊẒµ¬TạþTṂ€µ»İS

Try it online!
-1 thanks to Jonathan Allan
Did a lot of fiddling with compressed strings and ȷ literals before I realized that division by zero gives infinity. Takes input as an integer, since conversion to a digit list is one byte shorter (D versus V€)--and since half of the test cases have leading zeroes, which the spec also guarantees an integer-input solution never has to handle, here's the string version as well.
Jonathan Allan's golf cleverly avoids having to distinguish two different sources of zeroes by not finding the distances between holy digits and themselves.
Dµ                   Consider the decimal digits of the input.
  +Ị                 Increment 0s to 1s and 1s to 2s.
    Ẓ                For each digit, is it prime?
     µ               With this list of 0s for holy digits and 1s for holy digits,
        ạþ           table the absolute differences between
      ¬T             the indices of holy digits
          T          and the indices of unholy digits.
           Ṃ€        Take the minimum from each row,
                S    and sum
              »      the maxima of those minima and
             µ İ     their inverses.

Very nice. I made quite a few changes but got it down to 17 like this.

... or go old-school like this :)

R, 100 bytes
sum(sapply(0:(d=log10(n<-scan()))+1,function(x)min(abs(x-which(n%/%10^(0:d)%%10%in%c(0,4,6,8,9))))))

Try it online!

Python 3, 96 bytes
lambda s:sum(min([9e999]+[abs(i-j)for j,c in enumerate(s)if c in'04689'])for i in range(len(s)))

Try it online!

JavaScript (Node.js), 77 bytes
s=>s.reduce((m,c,i)=>m+Math.min(...s.map(c=>(i*i--)**.5+(174&1<<c?1/0:0))),0)

Try it online!


text:
Generate combinations with replacement
List all of the combinations with replacement (or combinations with repetition) of size k from a set of n elements.
A combination with replacement is an unordered multiset that every element in it are also in the set of n elements. Note that:

It is unordered. So a previously printed set with a different order shouldn't be printed again.
It is a multiset. The same element can (but isn't required to) appear more than once. This is the only difference between a combination with replacement and a normal combination.
The set should have exactly k elements.

Alternatively, it is also a size-k subset of the multiset which contains each of the n elements k times.
The input should be either n and k, where the elements are the first n positive or non-negative integers, or the n elements and k, where you can assume the n elements are all different from each other.
The output should be a list of all the combinations with replacement with size k from the given set. You can print them and the elements in each of them in any order.
You may not use builtins generating combinations with replacement. But you can use builtins to generate normal combinations, permutations, tuples, etc.
This is code-golf, shortest code wins.
Example
Input: 4 2
Output: [0 0] [0 1] [0 2] [0 3] [1 1] [1 2] [1 3] [2 2] [2 3] [3 3]

Jelly, 4 bytes
Thanks to Sp3000 for saving 2 bytes.
ṗṢ€Q

Input is n and k as command-line arguments in that order. Uses elements 1 to n.
Try it online!
Explanation
ṗ     # Get k-th Cartesion power of n.
 Ṣ€   # Sort each tuple.
   Q  # Remove duplicates.

CJam (8 bytes)
{m*:$_&}

Online demo
Dissection
{    e# Declare block (anonymous function); parameters are n k
  m* e# Cartesian product, which implicitly lifts n to [0 1 ... n-1]
  :$ e# Sort each element of the Cartesian product, to give them canonical forms
  _& e# Deduplicate
}

MATL, 11 bytes
(There's a 9-byte solution based on Cartesian power, but Peter Taylor already did that. Let's try something different).
Combinations with replacement can be reduced to combinations without replacement as follows. We want n Cr k, for example with n=3, k=2:
0 0
0 1
0 2
1 1
1 2
2 2

We can compute n+k-1 C k:
0 1
0 2
0 3
1 2
1 3
2 3

and then subtract 0 1 ... k-1 from each row:
+q:2GXn2G:-

Explanation:
+q     % take two inputs n, k and compute n+k-1
:      % range [1,2...,n+k-1]
2G     % push second input, k
Xn     % combinations without replacement
2G:    % range [1,2,...,k]
-      % subtract with broadcast. Display

The code works in release 13.1.0 of the language/compiler, which is earlier than the challenge.
You can try it online! Note that the online compiler has been updated to release 14.0.0, so Xn needs to be changed to XN.

Mathematica, 31 29 bytes
Thanks to A Simmons for saving 2 bytes.
{}⋃Sort/@Range@#~Tuples~#2&

An unnamed function taking n and k as integer arguments in that order and returning a list of lists. The elements will be 1 to n. Works the same as Peter's CJam answer.

@jimmy23013 Not one I'm aware of.

I think you can save two bytes with {}∪Sort/@Range@#~Tuples~#2&

@ASimmons Nice idea, thank you!

JavaScript (Firefox 30-57), 71 bytes
f=(n,k)=>k?[for(m of Array(n).keys())for(a of f(m+1,k-1))[...a,m]]:[[]]

I get to use keys() for once.

Ruby, 56 55 bytes
Two solutions, surprisingly both the same length:
->n,k{[*1..n].repeated_permutation(k).map(&:sort).uniq}
->n,k{(a=[*1..n]).product(*[a]*(k-1)).map(&:sort).uniq}

Hey, you did say we could use permutation builtins...
This simply generates all repeated permutations (the second one generates repeated Cartesian products) and removes ones that aren't in sorted order.
Thanks to Martin for saving a byte with 0...n -> 1..n!

Dyalog APL, 22 bytes
{∪{⍵[⍋⍵]}¨↓⍉⍺⊥⍣¯1⍳⍺*⍵}

Requires ⎕IO←0, which is default in many APL systems. Takes k as left argument, n as right argument.
⍳⍺*⍵ 0 1 2 ... kⁿ
⍺⊥⍣¯1 convert to base k
⍉ transpose
↓ make matrix into list of lists
{⍵[⍋⍵]}¨ sort each...
∪ the unique

Pyth, 7 bytes
{SM^UQE

Uses the same algorithm as Peter's answer.
    UQ   range(input())
      E  input()
   ^     repeated Cartesian product of ^^, ^ times
 SM      map(sort)
{        uniq

Python 3, 81 80
Recursive solution:
t=lambda n,k,b=0:[[]]if k<=0 else [[i]+l for i in range(b,n)for l in t(n,k-1,i)]

The function t(n, k, b) returns the list of all k-element multi-subsets of the range from b to n. This list is empty if k <= 0. Otherwise, we break the problem down based on the smallest element of the multi-subset, which we denote by i.
For each i in the range from b to n, we generate all of the k-multi-subsets with smallest element i by starting with [i] and then appending each (k-1)-multi-subset of the range from i to n, which we obtain by recursively calling t(n, k-1, i).

Welcome to Programming Puzzles & Code Golf! This is a nice first answer. Could you provide an explanation of how the code works?

Looks great. Nice solution!

Python, 63 bytes
f=lambda n,k:n*k and[l+[n]for l in f(n,k-1)]+f(n-1,k)or[[]][k:]

A recursive method. To make a multiset of k elements, 1 to n, we choose to either:

Include another instance of n, and it remains to make a multiset of k-1 elements from 1 to n
Don't include another instance of n, and it remains to make a multiset of k elements from to 1 to n-1

We terminate when either k or n reaches 0, and if it k reached 0, we give a base case of the empty list. If not, we have the wrong number of elements, and so give the empty list.

J, 18 bytes
[:~.#~<@/:~@#:i.@^

Similar approach used in @Adám's solution.
Another approach using Cartesian product { for 24 bytes. Takes k on the LHS and n on the RHS.
~.@:(/:~&.>)@,@{@(#<@i.)

Usage
   f =: [:~.#~<@/:~@#:i.@^
   4 f 2
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│0 0│0 1│0 2│0 3│1 1│1 2│1 3│2 2│2 3│3 3│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘

Explanation
[:~.#~<@/:~@#:i.@^ Input: n on LHS and k on RHS
                 ^ Compute n^k
              i.@  Create a range [0, 1, ... n^k-1]
    #~             Create k copies on n
            #:     On each value in the range above, convert each digit to base-n
                   and take the last k digits of it
        /:~@       For each array of digits, sort it in ascending order
      <@           Box each array of digits
[:~.               Take the distinct values in the array of boxes and return it

Clojure, 94 bytes
(defn f[k n](if(= 1 k)(for[i(range n)][i])(sort(set(for[i(f(dec k)n)j(range n)](conj i j))))))

Note the changed parameter order: 1st is k and 2nd is n. This saved 1 byte in (f(dec k)n).

Mathematica, 36 bytes
{##}&~Array~Table@##~Flatten~(#2-1)&

Please tell me there's a 1/6 bonus for using no []s...Or maybe for the many uses of ##?


text:
Draw an ASCII house
This is a window:
---
| |
---

Let's add some walls |. Put two spaces on either side of it so that the window has plenty of room.
|  ---  |
|  | |  |
|  ---  |

Now let's add a roof and a ceiling. To keep the window in the middle of the room, let's add one more row above it and below it.
---------
|       |
|  ---  |
|  | |  |
|  ---  |
|       |
---------

Now, just add a roof. Put a slash as far left as possible, and a backslash as far right as possible, and we have this:
/       \
---------
|       |
|  ---  |
|  | |  |
|  ---  |
|       |
---------

Then move the slash up one and right one. Move the backslash up one and left one:
 /     \
/       \
---------
|       |
|  ---  |
|  | |  |
|  ---  |
|       |
---------

Repeat until the two slashes meet, then add an asterisk where they meet:
    *
   / \
  /   \
 /     \
/       \
---------
|       |
|  ---  |
|  | |  |
|  ---  |
|       |
---------

And you're done! This is a 1x1 house. a 2x2 house would look like this:
        *
       / \
      /   \
     /     \
    /       \
   /         \
  /           \
 /             \
/               \
-----------------
|       |       |
|  ---  |  ---  |
|  | |  |  | |  |
|  ---  |  ---  |
|       |       |
|-------|-------|
|       |       |
|  ---  |  ---  |
|  | |  |  | |  |
|  ---  |  ---  |
|       |       |
-----------------

and a 3x2 house:
            *
           / \
          /   \
         /     \
        /       \
       /         \
      /           \
     /             \
    /               \
   /                 \
  /                   \
 /                     \
/                       \
-------------------------
|       |       |       |
|  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |
|       |       |       |
|-------|-------|-------|
|       |       |       |
|  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |
|       |       |       |
-------------------------

The challenge
You must write a full program that takes two integers, x and y, and prints a house that is X rooms wide and Y rooms tall. Your program should be able to handle houses up to 10x10. IO can be in any reasonable format. Trailing spaces on each line are allowed, and one trailing newline is allowed.
Shortest answer in bytes wins.

Vim 122, 89 Keystrokes
"aDJ"bD9i-<esc>Y2pVr <C-v>jr|$.Y4p3l<C-v>jljlr-jR| |<esc>{l<C-v>}d@apjdG@bp}Vr-{YPVr r/$r\qqYPllxx|P@qq@qddr*

Try it online!
I've improved my vim-golfing skills significantly since I posted this answer, so I decided to go back and write this whole thing from scratch. Saved thirty-three bytes in the process!
Input is assumed to be on two separate lines, so that the buffer looks like this before you start typing:
3
4

I had a very detailed explanation, but I don't feel like writing it all over again from the beginning... >_< Check out the revision history if you still want to see it.

Python 3.6 (pre-release), 221 210 203 bytes
x,y=eval(input())
w=8*x+1;p='-'*w+'\n'
for v in['*',*[f'/{" "*i}\\'for i in range(1,w-1,2)],p+p.join([''.join(f'{"".join([f"|{(a*3)[:3]:^7}"]*x)}|\n'for a in(*' -','| |',*'- '))]*y)+p]:print(v.center(w))

Reads 2 integers (separated by comma) from stdin, prints the house to stdout.
Readable version:
x, y = eval(input())
w = 8 * x + 1 # total width (in characters)
p = '-' * w + '\n' # floors
for v in [
    '*', # asterisk
    *[f'/{" "*i}\\' for i in range(1, w-1, 2)], # roof
    p + p.join([''.join(f'{"".join([f"|{(a*3)[:3]:^7}"]*x)}|\n' for a in (*' -','| |',*'- '))]*y) + p # rooms
]:
    print(v.center(w))

Which 3.6.0a0 feature/s does this use? Just f'{name}' string formatting?

@tac: only f-strings, yes

How did you install 3.6? I've been eagerly waiting for f-strings, but couldn't figure out how to install it myself (then again, Cygwin support isn't great)

@Sp3000: I built it from source

@Sp3000 Python 3.3+ won't build on Cygwin.

Where do you even get 3.6 prerelease? I can't find the source, anywhere.

@tac: you'll have to clone the official repository of CPython.

Python 2, 190 181 bytes
w,h=input();W=w*4
for i in range(~W,h*6+1):print['-'[i%(h*6):]*(W-~W)or['  %s  '%' -|-  - -  -|- '[~i%6::5],'-'*7][i%6<1].join('|'*-~w),' '*~i+['/%*c'%(w*8-~i*2,92),'*'][W<-i]][i<0]

Pretty sure there's much to golf, especially the windows, but here's something for now. Input width and height comma-separated, e.g. 1,2.
Quick and rough explanation:
                *          <--- i = ~W = -w*4 - 1.    <---\
               / \         <--\ i = -W = -w*4             | Preceding spaces
              /   \           |                           | are calculated
             /     \          |                           | the same way
            /       \      <--/ i = -1                <---/
   /--->    ---------      <--- i = 0
   |        |       |      <--\ i = 1                 <---\
Check       |  ---  |         |                           | Calculate inner string
i%(h*6)     |  | |  |         |                           | and use to join '|'s
is zero     |  ---  |         |                           | (ditto with |-------|)
   |        |       |      <--/ i = h*6 - 1           <---/
   \--->    ---------      <--- i = h*6

            ^       ^
            \-------/

          W-~W = w*8 + 1

JavaScript (ES6), 292 270 238 215 200 bytes
Thanks @Neil for helping trim this down!
a=>b=>[(p=(c,d=' ')=>d.repeat(c))(m=4*a)+'*',...[...Array(m)].map((c,i)=>p(--m)+`/${p(i*2+1)}\\`),y=p(8*a+1,'-')].join`
`+p(b,`
`+[x=p(a,'|'+p(7)),w=p(a,'|  ---  '),p(a,'|  | |  '),w,x,y].join`|
`)

Call as: F(a)(b)
Builds the roof, then assembles the core house with layered string repeats.

When I saw your answer I pondered whether you should have used join`|\n`  and now I wish I had commented at the time. It would have been a good excuse to add to my partial comment suggesting you use 9*a at some point, which I never submitted because it was too short.

Your formula 4*a-1 looks incorrect, I think it should be 4*a, this would incidentally save you 4 bytes.

m-i-1 becomes --m. 9*a-a becomes 8*a.

Now, you're not actually using any templates in your strings, and you could have done `*\n${[...Array(m)].map(...).join`\n`}\n` but you can go one better and join the string before and after at the same time: a=>b=>(p=(c,d=' ')=>d.repeat(c),[p(m=4*a)+`*`,...[...Array(m)].map((c,i)=>p(--m)+'/'+p(i*2+1)+'\\'),y=p(8*a+1,'-')].join`\n`+p(b,`\n`+[x=p(a,'|       '),w=p(a,'|  ---  '),p(a,'|  | |  '),w,x,y].join`|\n`))

@Neil You were right on the incorrect formula; that console log quotation was throwing me off a space. I've been slowly whittling away at this from my phone, and alot of the things I noticed you caught as well, but you got alot more out of it than I did. Thanks :)

@Neil Saved another 2 with x=p(a,'|'+p(7)), down to 203! If we can find 4 more bytes, we can break below 200! :D (although I doubtful of finding 4 more...)

Shave off one more byte with \/${p(i*2+1)}\``.

@Neil Right up to the very edge, but I think we've milked this for all it's worth. Thanks for your help :3

Ruby, Rev B 165 bytes
w=1-2*r=-4*x=gets.to_i
puts (r-1..h=6*gets.to_i).map{|n|n<0?(n<r ??*:?/+' '*(w+n*2)+?\\).center(w):n%h<1?(?-*w):'|CCBABCC'.tr('CBA','   | \-'[1222>>n%6*2&6,3])*x+?|}

uses a single loop and several other golfing tricks.
Ruby, Rev A 179 bytes
w=1+8*x=gets.to_i
y=gets.to_i
b=(0..x*4).map{|n|(n<1??*:?/+' '*(n*2-1)+?\\).center(w)}
a=(2..y*6).map{|n|('|CCBABCC'.tr('CBA','   | \\-'[4888>>n%6*2&6,3]))*x+?|}
puts b,s=?-*w,a,s

Ungolfed
  x=gets.to_i
  y=gets.to_i

  w=x*8+1                                  #calculate width of house

  b=(0..x*4).map{|n|                       #design a roof line by line
    (n<1??*:?/+' '*(n*2-1)+?\\).center(w)  #first line is *, second line is /[spaces]\
  }                                        #centre correctly to the width of the house by padding

  a=(2..y*6).map{|n|                       #design a front facade line by line
    ('|CCBABCC'.                           #template for each row
      tr('CBA','   | \\-'[4888>>n%6*2&6,3])#substitute CBA for 3 characters from the string according to magic number 4888
    )*x+?|                                 #we need x copies, finishing with a |
  }

  puts b,s=?-*w,a,s                        #print a roof, a line of -, a facade and another line of -

I think you can drop one of the backslashes in the string, i.e. | \-'.

@Sp3000 That does work, thanks. I guess \- doesn't mean anything as an escape sequence, so the \- is just parsed as 2 characters. Then of course - has a special meaning to tr, so we need the string ' \-' for the windows to escape the - (mapping C-> space, B->- and A->- as there are no more characters left.) For the floors, we have only the string '-' and in this case tr seems happy to interpret it just as a literal rather than a special character, assigning C=B=A = '-' All in all it was a tricky thing to get working. I'm sure there's more golfing to do, will edit later.

C++, 258 Bytes Test Here
#include<cstdio>
int main(){for(int r=10,c=10,x,y,q,u,h=c*4,w=h*2,i=0;i<h+r*8+2;i++)for(q=0;q<w+2;q++)x=q%8,y=i%8,u=(i-(h+1))%8,putchar(q==w+1?10:i<=h?!i&&q==h?42:i==h-q?47:i==q-h?92:32:!u||(u==3||u==5)&&x>2&&x<6?45:!x||u==4&&(x==3||x==5)?124:32);return 0;}

Result:
                                        *
                                       / \
                                      /   \
                                     /     \
                                    /       \
                                   /         \
                                  /           \
                                 /             \
                                /               \
                               /                 \
                              /                   \
                             /                     \
                            /                       \
                           /                         \
                          /                           \
                         /                             \
                        /                               \
                       /                                 \
                      /                                   \
                     /                                     \
                    /                                       \
                   /                                         \
                  /                                           \
                 /                                             \
                /                                               \
               /                                                 \
              /                                                   \
             /                                                     \
            /                                                       \
           /                                                         \
          /                                                           \
         /                                                             \
        /                                                               \
       /                                                                 \
      /                                                                   \
     /                                                                     \
    /                                                                       \
   /                                                                         \
  /                                                                           \
 /                                                                             \
/                                                                               \
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |       |       |
|       |       |       |       |       |       |       |       |       |       |
---------------------------------------------------------------------------------

This does not match OP's image. Pitch of storeys is higher, and in OP's image only the top and bottom floors are solid lines of -. The intermediate floors are broken up with |

@steveverrill Thanks for pointing that out, I made the exact same mistake in my own submission. fp.

238 bytes

C++, 282 bytes, fixes the problems with the previous entry:
#include<cstdio>
int main(){for(int r=2,c=2,x,y,q,u,h=c*4,w=h*2,i=0;i<h+r*6+2;i++)for(q=0;q<w+2;q++)x=q%8,y=i%8,u=(i-h-1)%6,putchar(q==w+1?10:i<=h?!i&&q==h?42:i==h-q?47:i==q-h?92:32:!u&&x||!u&&(i<h+2||i==h+r*6+1)||(u==2||u==4)&&x>2&&x<6?45:!x||u==3&&(x==3||x==5)?124:32);return 0;}

Output:
        *
       / \
      /   \
     /     \
    /       \
   /         \
  /           \
 /             \
/               \
-----------------
|       |       |
|  ---  |  ---  |
|  | |  |  | |  |
|  ---  |  ---  |
|       |       |
|-------|-------|
|       |       |
|  ---  |  ---  |
|  | |  |  | |  |
|  ---  |  ---  |
|       |       |
-----------------

C#, 361 353 bytes
string b(int w,int h){string m="",s,f,o=m,x,y,n="\n",p="|",q=" ";int i=0,v=w*4;Func<int,string,string>r=(j,c)=>{for(s="";j-->0;)s+=c;return s;};m+=r(v,q)+"*\n";for(;i<v;)m+=r(v-i-1,q)+'/'+r(i++*2+1,q)+"\\\n";f=r(w*8+1,"-");m+=f;x=n+r(w,p+r(7,q))+p;y=n+r(w,"|  ---  ")+p;o=x+y+n+r(w,"|  | |  ")+p+y+x;for(i=1;i++<h;)m+=o+x.Replace(q,'-');return m+o+n+f;}

Full Program:
using System;
class House
{
    static int Main()
    {
        var x = new House();
        Console.WriteLine(x.b(1,1));
        Console.WriteLine();
        Console.WriteLine(x.b(2,2));
        Console.WriteLine();
        Console.WriteLine(x.b(2,3));
        Console.WriteLine();
        Console.WriteLine(x.b(9,9));
        Console.WriteLine();
        Console.Read();
        Console.WriteLine(x.b(10, 10)); // Looks broken because Bash to small
        Console.Read();
        return 0;
    }

    string b(int w,int h){string m="",s,f,o=m,x,y,n="\n",p="|",q=" ";int i=0,v=w*4;Func<int,string,string>r=(j,c)=>{for(s="";j-->0;)s+=c;return s;};m+=r(v,q)+"*\n";for(;i<v;)m+=r(v-i-1,q)+'/'+r(i++*2+1,q)+"\\\n";f=r(w*8+1,"-");m+=f;x=n+r(w,p+r(7,q))+p;y=n+r(w,"|  ---  ")+p;o=x+y+n+r(w,"|  | |  ")+p+y+x;for(i=1;i++<h;)m+=o+x.Replace(q,'-');return m+o+n+f;}

    // Without extra vars
    string b1(int w, int h)
    {
        string m = "", s, f, o = m, x, y;
        int i = 0, v = w*4;
        Func<int,string,string> r = (j,c) => {
            for(s = ""; j-->0;) s += c;
            return s;
        };
        /// Roof
        m += r(v, " ") + "*\n";
        for (; i < v;) m += r(v - i - 1, " ") + '/' + r(i++ * 2 + 1, " ") + "\\\n";
        /// Ceiling
        f = r(w * 8 + 1, "-");
        m += f;
        /// Room
        x = "\n" + r(w, "|" + r(7, " ")) + "|";
        y = "\n" + r(w, "|  ---  ") + "|";
        o = x + y + "\n" + r(w, "|  | |  ") + "|" + y + x;
        for (i = 1; i++ < h;) m += o + x.Replace(' ','-');
        /// Floor
        return m + o + "\n" + f;
    }

    string build(int width, int height)
    {
        // House, tempStr, floor, room, x/y = room_row1/2
        string house = "", s, ceil, room = "", x, y;
        int i, v = width*4;
        Func<int,string,string> rep = (j,c) => {
            s = "";
            for(; j>0; j--) s += c;
            return s;
        };
        /// Roof
        house += rep(v, " ") + "*\n";
        for (i = 0; i < v;) {
            // LEFT Indent + '/' + Distance + '\'
            house += rep(v - i - 1, " ") + '/' + rep(i++ * 2 + 1, " ") + "\\\n";
        }
        /// Ceiling
        ceil = rep(width * 8 + 1, "-");
        house += ceil;
        /// Room
        x = "\n" + rep(width, "|" + rep(7, " ")) + "|";
        y = "\n" + rep(width, "|  ---  ") + "|";
        room = x + y + "\n" + rep(width, "|  | |  ") + "|" + y + x;
        for (i = 1; i < height; i++) {
            house += room;// + x.Replace(' ','-');
            house += "\n" + rep(width, "|" + rep(7, "-")) + "|";
        }
        /// Floor
        house += room + "\n" + ceil;
        return house;
    }
}

Nice, couple of general tips that apply here: you can save a handful of characters by taking a closer look at some of your for-loops (s="" can be put inside the for(j) loop (consider j-->0 for the condition as well, and i++<h in the last loop), i=0 can be moved out of the for loop into the declaration saving a byte. You can also save a byte by reusing assigned empty strings (once m is assigned, you can assign o=m saving the "". Replace also takes strings, so you can use your q instead of ' ', and there is no need for the space after the > when declaring r. Small things ;)

Sometimes it's the small things that make the difference. Thanks :D

VBA, 284 bytes
Function H(W,S)
L=vbLf:H=Space(4*W)&"*"&L
For R=1 To 4*W:H=H &Space(4*W-R)&"/"&Space(2*R-1)&"\"&L:Next
J=".":P=String(W,J)&"|"&L
D=String(8*W+1,"-")&L
E=Replace(P,J,"|       ")
F=Replace(P,J,"|  ---  ")
H=H &Replace(String(S,J),J,D &E &F &Replace(P,J,"|  | |  ")&F &E)&D
End Function

The Replace function is a neat tool for making multiple copies in a way that the String function unfortunately doesn't want to.
Invoke for best effect in the Immediate window of the VBA editor: ?H(8,8) for example.
?H(8,8)
                                *
                               / \
                              /   \
                             /     \
                            /       \
                           /         \
                          /           \
                         /             \
                        /               \
                       /                 \
                      /                   \
                     /                     \
                    /                       \
                   /                         \
                  /                           \
                 /                             \
                /                               \
               /                                 \
              /                                   \
             /                                     \
            /                                       \
           /                                         \
          /                                           \
         /                                             \
        /                                               \
       /                                                 \
      /                                                   \
     /                                                     \
    /                                                       \
   /                                                         \
  /                                                           \
 /                                                             \
/                                                               \
-----------------------------------------------------------------
|       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |
-----------------------------------------------------------------
|       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |
-----------------------------------------------------------------
|       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |
-----------------------------------------------------------------
|       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |
-----------------------------------------------------------------
|       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |
-----------------------------------------------------------------
|       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |
-----------------------------------------------------------------
|       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |
-----------------------------------------------------------------
|       |       |       |       |       |       |       |       |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |  | |  |
|  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |  ---  |
|       |       |       |       |       |       |       |       |
-----------------------------------------------------------------

APL (Dyalog Extended), 91 bytes
'*'↑⍨-1+3×w←⎕
' /'[⊖a],' ',' \'[a←∘.=⍨⍳w×3]
' |-'[2⍪⍨2⍪¯1↓⊃⍪/⎕⌿⊂1,⍨⊃,/w/⊂⍉3⊤269+⎕AV⍳'4 4#']

Try it online!
Full program, takes columns, then rows, on separate lines.

Vyxal, 76 bytes
4*:×꘍,(¹4*n-‹\/꘍nd›\\꘍+,)¹8*›¤-?(…\|7꘍¹*\|+…\|:2꘍2-ømṪ¹*$+…»ŀ»‛ |τ¹*\|+,,,),

Try it Online!
A. Mess.


text:
Convert to camelCase
The Challenge
I was reading Google's Java Style Guide the other day and stumbled over their algorithm to convert any arbitrary string into camelCase notation. In this challenge you have to implement this algorithm since you don't want to do all this stuff in your head when you are writing your super competitive Java submissions to code-golf challenges.
Note: I made some small adjustments to the algorithm. You need to use the one specified below.
The algorithm
You start with an arbitrary input string and apply the following operations to it:

Remove all apostrophes `'
Split the result into words by splitting at

characters that are not alphanumerical and not a digit [^a-zA-Z0-9]
Uppercase letters which are surrounded by lowercase letters on both sides. abcDefGhI jk for example yields abc Def Ghi jk

Lowercase every word.
Uppercase the first character of every but the first word.
Join all words back together.

Additional notes

The input will only contain printable ASCII.
If a digit is the first letter in a word, leave it as it is and don't capitalize something else in this word.
The input will always have at least one character.

Rules

Function or full program allowed.
Default rules for input/output.
Standard loopholes apply.
This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.

Test cases

"Programming Puzzles & Code Golf" -> "programmingPuzzlesCodeGolf"
"XML HTTP request" -> "xmlHttpRequest"
"supports IPv6 on iOS?" -> "supportsIpv6OnIos"
"SomeThing w1th, apo'strophe's and' punc]tuation" -> "someThingW1thApostrophesAndPuncTuation"
"nothing special" -> "nothingSpecial"
"5pecial ca5e" -> "5pecialCa5e"
"1337" -> "1337"
"1337-spEAk" -> "1337Speak"
"whatA mess" -> "whataMess"
"abcD" -> "abcd"
"a" -> "a"
"B" -> "b"

Happy Coding!

Interesting, I never knew this was called "camelCase". Name is fitting I suppose...

There are more: snake_case & PascalCase

@Martijn snake_case because of Python, of course. FORTH also has FORTHCASE and APL has unreadable in any case

Test case 4 should have ApostropheS in the output.

@Titus No, it is correct. Apostrophes are removed before the input is splitted.

What´s the result for "whatA mess"?

@Titus Result for that should be "whataMess". I added a test case for that now.

oh I just saw that the answer had already been in "abcD" Are multiple spaces between words allowed in output?

@Titus I suppose you mean the input, since the output can't have any spaces in it. And yes, the input might have multiple spaces, but it shouldn't really matter since you split on them anyway.

Retina, 56 bytes
Byte count assumes ISO 8859-1 encoding.
T`'\`
S_`\W|_|(?<=[a-z])(?=[A-Z][a-z])
T`L`l
T`l`L`¶.
¶

Try it online!
Explanation
This implements the specification quite literally:
T`'\`

Remove apostrophes and backticks.
S_`\W|_|(?<=[a-z])(?=[A-Z][a-z])

Split the string around non-word characters (in regex this also excludes digits and underscores), or underscores or positions that have a lower case letter on the left and and upper case, lower case on the right. This would create some empty segments when there are two non-letter, non-digit characters in a row, or more important at the beginning of the string. We get rid of those with the _ option. Here, "splitting" means put each remaining part on its own line.
T`L`l

Convert everything to lower case.
T`l`L`¶.

Convert each character that occurs after the linefeed to upper case. This will conveniently skip the first word because there's no linefeed in front of it.
¶

Get rid of the linefeeds to join everything back together.

You beat me to it. Nice one!

This question may be a bit weird, but...should I post my answer if it's shorter than yours and also in Retina? I was working on it before your answer appeared, but then it did and now I don't know if I should post it.

@daavko Sure, post it (I usually decide based on how different the approach is to the existing answer... if it's the exact same thing with a byte shaved off somewhere I normally just comment on that answer, but if it's a lot shorter of a different approach, then I'd just post a separate answer).

@MartinBüttner Now that I look at it, it's the same approach, but as a simple expression, rather than a difficult-to-understand (for me, at least) lookaround (or whatever it is). I'll just put it here as a comment: Try it online

@daavko The lookaround is necessary though. Note that your answer doesn't retain the capitalisation of Thing although it should.

@MartinBüttner Oh...I didn't notice that. Oh well, I'll successfully answer some other challenge, then.

Java, 198 190 bytes

+3 bytes because I forgot that \W+ == [^a-zA-Z0-9_]+ and I need to match [^a-zA-Z0-9]+
-11 bytes thanks to user20093 - ?: instead of if/else

Because, Java.
s->{String[]a=s.replaceAll("`|'","").split("[\\W_]+|(?<=[a-z])(?=[A-Z][a-z])");s="";for(String w:a){String t=w.toLowerCase();s+=a[0]==w?t:t.toUpperCase().charAt(0)+t.substring(1);}return s;}

This is a lambda. Call like so:
UnaryOperator<String> op = s->{String[]a=s.replaceAll("`|'","").split("[\\W_]+|(?<=[a-z])(?=[A-Z][a-z])");s="";for(String w:a){String t=w.toLowerCase();s+=a[0]==w?t:t.toUpperCase().charAt(0)+t.substring(1);}return s;};
System.out.println(op.apply("Programming Puzzles & Code Golf"));

Readable version:
public static String toCamelCase(String s) {
    String[] tokens = s
            .replaceAll("`|'", "") // 1. Remove all apostrophes
            .split("[\\W_]+|(?<=[a-z])(?=[A-Z][a-z])"); // 2. Split on [\W_]+ or between [a-z] and [A-Z][a-z]
    s = ""; // Reusing s for building output is cheap
    for (String token : tokens) {
        String lowercaseToken = token.toLowerCase(); // 3. Lowercase every word
        s += tokens[0].equals(token)?lowercaseToken:lowercaseToken.toUpperCase().charAt(0) + lowercaseToken.substring(1); // 4. Uppercase first char of all but first word
        // ^ 5. Join all words back together
    }
    return s;
}

It's not Swift...

Welcome to Programming Puzzles & Code Golf! This is a nice first answer!

@CatsAreFluffy What?

if you replace conditional statement(if/else) with conditional expression (?:) you could save around 9 bytes

Don't know how I missed that @user902383 - added for -11 bytes. Unfortunately I had to add 3 as well to match _ as a token delimiter.

JavaScript (ES6), 156 154 152 148 145 141 140 bytes
Thanks @Neil (6 bytes), @ETHproductions (3 bytes), and @edc65 (7 bytes)
a=>a[r='replace'](/`|'/g,a='')[r](/[a-z](?=[A-Z][a-z])/g,'$& ')[r](/[^\W_]+/g,b=>a+=(a?b[0].toUpperCase():'')+b.slice(!!a).toLowerCase())&&a

Removes apostrophes, then does a replace to split on special characters/before surrounded capitals, then combines with proper casing. Unfortunately, toLowerCase() and toUpperCase() are annoyingly long and hard to avoid here...

I was working on a different approach which your b.slice(i>0) approach blows out of the water, but in the mean time my match regex of /[A-Z]?([a-z0-9]|[0-9A-Z]{2,})+([A-Z](?![a-z]))?/g does appear to save 2 bytes over your otherwise ingenious replace approach.

Or I could just save 2 bytes on your replace directly: replace(/[a-z](?=[A-Z][a-z])/g,'$& ')

@Neal Good point on the replace lookahead! I'll opt for that one, since it takes the least change here. Still, nice matching construction =) I wish JS had lookbehind though...

Usually match...map can be replaced with replace

@edc65 I get a minimum of 160 bytes with that approach: a=>a.replace(/`|'/g,'').replace(/[a-z](?=[A-Z][a-z])/g,'$& ').replace(/[\W_]*([a-z0-9]+)[\W_]*/gi,(_,b,i)=>(i?b[0].toUpperCase():'')+b.slice(i>0).toLowerCase())

Just a first attempt 150: a=>a[r='replace'](/`|'/g,'')[r](/[a-z](?=[A-Z][a-z])/g,'$& ')[r](/[a-z0-9]+/gi,(b,i)=>a+=(i?b[0].toUpperCase():'')+b.slice(i>0).toLowerCase(),a='')&&a

@edc65 Combine that with ETH's alphanumeric regex, and it's down to 148. Mind if I use this?

I will be glad if you use some of my suggestions

145 if you move a='' at the beginning a=>a[r='replace'](/`|'/g,a='')[r](/[a-z](?=[A-Z][a-z])/g,'$& ')[r](/[^\W_]+/gi,(b,i)=>a+=(i?b[0].toUpperCase():'')+b.slice(i>0).toLowerCase())&&a

Ugh, I'd already tried using split(/[\W_]/) but I totally overlooked match/replace with /[^\W_]/...

On the other hand, I would like to offer b=>a+=(a?b[0].toUpperCase():'')+b.slice(!!a).toLowerCase() which I believe saves you another 4 bytes.

Make it tweet-able by removing the i from the third regex :-)

@ETHproductions do you regularly scan through 2/3rd year old submissions for 1 byte savings haha? Thanks =)

Haha, I just happened to run across this for some reason the other day, looked through the comments and noticed the i was still in the regex for some reason. I can't help it if I see an improvement to be made ;)

vim, 69 68 66
:s/[`']//g<cr>:s/[a-z]\zs\ze[A-Z][a-z]\|\W\|_/\r/g<cr>o<esc>guggj<C-v>GgU:%s/\n<cr>

vim shorter than Perl?! What is this madness?
:s/[`']//g<cr>           remove ` and '
:s/                      match...
 [a-z]\zs\ze[A-Z][a-z]   right before a lowercase-surrounded uppercase letter
 \|\W\|_                 or a non-word char or underscore
 /\r/g<cr>               insert newlines between parts
o<esc>                   add an extra line at the end, necessary later...
gugg                     lowercasify everything
j                        go to line 2 (this is why we added the extra line)
<C-v>G                   visual select the first char of all-but-first line
gU                       uppercase
:%s/\n<cr>               join all lines into one

Thanks to Neil for spotting a useless keystroke!

I can see why the last :s has a % but why the inconsistency in the first two?

@Neil Bah, muscle memory. Thanks!

Manages to be less readable than Perl, too +1

I'm totally adding this to my .vimrc

ggVGJ to join all lines?

@fruglemonkey 1. :%j<cr> is equivalent and shorter. 2. That adds spaces between lines.

Mathematica 10.1, 101 bytes
""<>(ToCamelCase@{##2}~Prepend~ToLowerCase@#&@@StringCases[StringDelete[#,"`"|"'"],WordCharacter..])&

Uses the undocumented ToCamelCase, which works similarly to Capitalize but sets other characters to lowercase.

Not in 10.3.0..

Is ToCamelCase[n_,m_]:=n<>Capitalize/@m correct? Seems like it. And why use Prepend when #~ToCamelCase~{##2} works?

@CatsAreFluffy That gives me ToCamelCase::argx: ToCamelCase called with 2 arguments; 1 argument is expected.

Well, how does CamelCase work? Just ToCamelCase[n_]:=""<>Capitalize/@n?

@CatsAreFluffy, see this.

Julia, 98 89 bytes
s->lcfirst(join(map(ucfirst,split(replace(s,r"['`]",""),r"[a-z]\K(?=[A-Z][a-z])|\W|_"))))

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.
The approach here is the same as in Doorknob's Perl answer: replace apostrophes and backticks with the empty string, split into an array on a regular expression that matches the necessary cases, map the ucfirst function over the array to uppercase the first letter of each element, join the array back into a string, and lcfirst the result to convert the first character to lowercase.

I've always liked Julia as a more functional, more interesting Python but I hate the end syntax. Maybe I'll just use anonymous functions for everything, then I never have to type end :D

Perl 67 + 1 = 68 bytes
y/'`//d;s/([a-z](?=[A-Z][a-z]))|\W|_/$1 /g;$_=lc;s/^ +| +(.)/\u$1/g

Requires the -p flag, and -l for multi line:
$ perl -pl camelCase.pl input.txt
programmingPuzzlesCodeGolf
xmlHttpRequest
supportsIpv6OnIos:
someThingW1thApostrophesAndPuncTuation
nothingSpecial
5pecialCa5e
1337
1337Speak
abcd

How it works:
y/'`//d;                            # Remove ' and `
s/([a-z](?=[A-Z][a-z]))|\W|_/$1 /g; # Replace according to '2. Split...' this will create
                                    #   a space separated string.
$_=lc;                              # lower case string
s/^ +| +(.)/\u$1/g                  # CamelCase the space separated string and remove any
                                    #   potential leading spaces.

Lua, 127 Bytes
t=''l=t.lower z=io.read()for x in z:gmatch('%w+')do t=t..(t==''and l(x:sub(1,1))or x:sub(1,1):upper())..l(x:sub(2))end return t

Accepts a string from stdin and returns camelized results.
Probably still gonna look for a better solution as storing everything in a variable feels inefficient.
But anyhow, pretty simple in general:
 z:gmatch('%w+')

This is the beauty that saved me a bit of bytes. gmatch will split the string based on the pattern: %w+ which grabs only alphanumerics.
After that it's simple string operations. string.upper, string.lower and done.

PHP, 145 122 133 bytes
<?=join(split(" ",lcfirst(ucwords(strtolower(preg_replace(["#`|'#","#\W|_#","#([a-z])([A-Z][a-z])#"],[""," ","$1 $2"],$argv[1]))))));

Save to file, call from CLI.
Takes input from a single command line argument; escape quotes and whitespace where necessary.
breakdown
<?=                 // 9. print result
join(split(" ",     // 8. remove spaces
    lcfirst(        // 7. lowercase first character
    ucwords(        // 6. uppercase first character in every word
    strtolower(     // 5. lowercase everything
    preg_replace(
        ["#`|'#",   "#\W|_#",   "#([a-z])([A-Z][a-z])#"],
        ["",        " ",        "$1 $2"],
        // 2. replace apostrophes with empty string (remove them)
                    // 3. replace non-word characters with space
                                // 4. insert space before solitude uppercase
        $argv[1]    // 1. take input from command line
    ))))
));

lcfirst allowed to reduce this to a single command, saving 23 bytes.
Fixing the apostrophes cost 11 bytes for the additional replace case.

Perl, 87 80 78 bytes
y/'`//d;$_=join'',map{ucfirst lc}split/[a-z]\K(?=[A-Z][a-z])|\W|_/,$_;lcfirst

Byte added for the -p flag.
First, we use the y/// transliteration operator to delete all '` characters in the input:
y/'`//d;

Then comes the meat of the code:
                         split/[a-z]\K(?=[A-Z][a-z])|\W|_/,$_;

(split the input string $_ in the appropriate locations, using the fancy \K in the match string to exclude the portion preceding it from the actual match)
          map{ucfirst lc}

(map over each split portion of the string and make the entire string lowercase, then make the first character of the modified string uppercase)
$_=join'',

(join on empty string and re-assign to magic underscore $_, which gets printed at the end)
Finally, we lowercase the first letter by regex-matching it and using \l in the replacement string with a builtin, saving 2 bytes over the previous method:
lcfirst

Thanks to @MartinBüttner for 7 bytes ([^a-zA-Z\d] -> \W|_)!

How I envy that \K... ;)

Scala, 181 170 144
def f(s:String)={val l=s.replaceAll("'|`","")split("[\\W_]+|(?<=[a-z])(?=[A-Z][a-z])")map(_.toLowerCase);l(0)+l.tail.map(_.capitalize).mkString}

Tester:
val testCases = List(
  "Programming Puzzles & Code Golf" -> "programmingPuzzlesCodeGolf",
  "XML HTTP request" -> "xmlHttpRequest"
  // etc
)
println(testCases.map(t=>if(t._2!=f(t._1))s"FAIL:${f(t._1)}"else"PASS").mkString("\n"))

Props to CAD97 and apologies to Nathan Merrill :)

You can save 6 bytes by replacing [^a-zA-Z0-9]+ with [\\W_]+.

Kotlin, 160 Bytes
fun a(s: String)=s.replace(Regex("['`]"),"").split(Regex("[\\W_]+|(?<=[a-z])(?=[A-Z][a-z])")).map{it.toLowerCase().capitalize()}.joinToString("").decapitalize()

My goal was to be Scala, the other "alternative Java", so I'm somewhat happy with my results.  I stole the regex from the Java answer.
Test it with:
fun main(args: Array<String>) {
    val testCases = arrayOf(
            "Programming Puzzles & Code Golf",
            "XML HTTP request",
            "supports IPv6 on iOS?",
            "SomeThing w1th, apo'strophe's and' punc]tuation",
            "nothing special",
            "5pecial ca5e",
            "1337",
            "1337-spEAk",
            "abcD",
            "a",
            "B")
    testCases.forEach { println(a(it)) }

}

At this point I think everyone is "borrowing" the optimized regex \W|_|(?<=[a-z])(?=[A-Z][a-z]) or slightly modifying it eg. [\W_]+

you can save some on map and extension function fun String.a()=replace(Regex("['\]"),"").split(Regex("[\W_]+|(?<=[a-z])(?=[A-Z][a-z])")).joinToString(""){it.toLowerCase().capitalize()}.decapitalize()`

C 272 characters
C program pass string to camelCase in quotes as argument 1.  There are lot's of gotchas in this problem statement...
#define S strlen(t)
#define A isalnum(t[i])
j=0;main(i,v)char**v;{char*p=v[1],*t;char o[99]={0};while(t=strtok(p," [{(~!@#$%^*-+=)}]")){i=0;p+=S+1;while((!A)&&i<S)i++;if(i!=S){o[j]=((j++==0)?tolower(t[i++]):toupper(t[i++]));while(i<S){if(A)o[j++]=t[i];i++;}}}puts(o);}

You need to #include<string.h> for strlen, strtok, and toupper, and #include<ctype.h> for isalnum.

I didn't need it using gcc 3.4.4 in cygwin.  They must be automatically linked in, assuming extern int.

With ./camel "Programming Puzzles & Code Golf" on cygwin (compiled with gcc 3.4.4), I get programmingPuzzlesCodeEGolf. Same output with 5.3.0.

Crap. me too.  I must've created a bug while golfing it.  I'm looking at it now...

The problem was I added the other tokenizer strings after golfing and didn't test it well enough.  If you remove the '&' from the strtok call it works on that input.

JavaScript, 123 bytes
v=>v[r="replace"](/[`']/g,"")[r](/^.|.$|[A-Z][^a-z]+/g,x=>x.toLowerCase())[r](/[^a-z0-9]+./ig,x=>x.slice(-1).toUpperCase())

Readable version
v=>
  v.replace(/[`']/g,"")
  .replace(/^.|.$|[A-Z][^a-z]+/g,x=>x.toLowerCase())
  .replace(/[^a-z0-9]+./ig,x=>x.slice(-1).toUpperCase())

Remove the apostrophes,
make the first character lower case, the last character lowercase, and any grouping of multiple uppercase characters,
match any group of 1 or more non-alphanumeric chars + 1 other character, replace with that last character capitalized.
[r="replace"] trick from Mrw247's solution.

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