Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
3 added 35 characters in body
source | link

R, 30 2727 22 bytes

Current solution due to user11599!

rev(revhead(scan(,'')[,-1]1)[-1])

Takes input from stdin, returns each middle name as a separate string. Returns character() in the case of no middle name; that is, a vector of class character of length 0.

Explanation:

Read stdin into a list of strings, separated by spaces

        scan(,'')

Remove the firstlast element (i.e. head returns the first name)n elements of a list, with n defaulting to 6. If n is -1 it returns all but the last element.

        head(scan(,'')[,-1]1)

Reverse this listNow, and remove the first element (i.e. the surname)of this list.

    revhead(scan(,'')[,-1]1)[-1])

Reverse this list again, and it'sThis yields the middle name(s) in the original order.

rev(rev(scan(,'')[-1])[-1])

R, 30 27 bytes

rev(rev(scan(,'')[-1])[-1])

Takes input from stdin, returns each middle name as a separate string. Returns character() in the case of no middle name; that is, a vector of class character of length 0.

Explanation:

Read stdin into a list of strings, separated by spaces

        scan(,'')

Remove the first element (i.e. the first name).

        scan(,'')[-1]

Reverse this list, and remove the first element (i.e. the surname).

    rev(scan(,'')[-1])[-1])

Reverse this list again, and it's the middle name(s) in the original order.

rev(rev(scan(,'')[-1])[-1])

R, 30 27 22 bytes

Current solution due to user11599!

head(scan(,''),-1)[-1]

Takes input from stdin, returns each middle name as a separate string. Returns character() in the case of no middle name; that is, a vector of class character of length 0.

Explanation:

Read stdin into a list of strings, separated by spaces

     scan(,'')

Remove the last element. head returns the first n elements of a list, with n defaulting to 6. If n is -1 it returns all but the last element.

head(scan(,''),-1)

Now, remove the first element of this list.

head(scan(,''),-1)[-1]

This yields the middle name(s).

2 added 405 characters in body
source | link

R, 3030 27 bytes

rev(n=scanrev(scan(,''))[-c(1,length(n1])[-1])]

Takes input from stdin, returns each middle name as a separate string. Returns character() in the case of no middle name; that is, a vector of class character of length 0.

Explanation:

Read stdin into a list of strings, separated by spaces

        scan(,'')

Remove the first element (i.e. the first name).

        scan(,'')[-1]

Reverse this list, and remove the first element (i.e. the surname).

    rev(scan(,'')[-1])[-1])

Reverse this list again, and it's the middle name(s) in the original order.

rev(rev(scan(,'')[-1])[-1])

R, 30 bytes

(n=scan(,''))[-c(1,length(n))]

Takes input from stdin, returns each middle name as a separate string. Returns character() in the case of no middle name; that is, a vector of class character of length 0.

R, 30 27 bytes

rev(rev(scan(,'')[-1])[-1])

Takes input from stdin, returns each middle name as a separate string. Returns character() in the case of no middle name; that is, a vector of class character of length 0.

Explanation:

Read stdin into a list of strings, separated by spaces

        scan(,'')

Remove the first element (i.e. the first name).

        scan(,'')[-1]

Reverse this list, and remove the first element (i.e. the surname).

    rev(scan(,'')[-1])[-1])

Reverse this list again, and it's the middle name(s) in the original order.

rev(rev(scan(,'')[-1])[-1])
1
source | link

R, 30 bytes

(n=scan(,''))[-c(1,length(n))]

Takes input from stdin, returns each middle name as a separate string. Returns character() in the case of no middle name; that is, a vector of class character of length 0.