[Question]
  [
[Elixir](https://elixir-lang.org/) is a programming language with a feature called the [pipe operator](https://elixirschool.com/en/lessons/basics/pipe-operator/), `|>`, similar to the pipe in Bash and other languages. It passes the result of an expression on the left as the first parameter of a given function on the right.
To clarify, here are some examples.
```
2 |> myFunction()
```
is equivalent to
```
myFunction(2)
```
Here, the expression `2` is passed as the first parameter of the function `myFunction()`.
Now, consider how an expression with multiple pipes is evaluated. Multiple pipes are evaluated left to right, so all of these lines are equivalent:
```
other_function() |> new_function() |> baz() |> bar() |> foo()
new_function(other_function()) |> baz() |> bar() |> foo()
baz(new_function(other_function())) |> bar() |> foo()
bar(baz(new_function(other_function()))) |> foo()
foo(bar(baz(new_function(other_function()))))
```
Here, in each line the leftmost pipe is calculated, which takes the first expression and passes it to the second expression (which is a function).
## Challenge
Your challenge will be to write a program or function which, when given an Elixir expression with one or more pipes, will return or output an equivalent expression with no pipes. In real Elixir code the functions may have multiple parameters but to keep this challenge simpler, you may assume all functions will take only one parameter.
## Examples
```
Input                                                       -> Output
2 |> myFunction()                                           -> myFunction(2)
otherfunction() |> newfunction() |> baz() |> bar() |> foo() -> foo(bar(baz(newfunction(otherfunction()))))
```
## Rules
* Function names will only contain ASCII letters and underscores, and end in `()`
* The leftmost expression will only contain alphanumeric ASCII, underscores, and parentheses
* You may assume there is no whitespace in the input (the examples here have spaces for readability)
* You may also assume there are spaces surrounding the pipe operators like in the examples, if you wish
* All functions only take one parameter
* Leading or trailing whitespace is allowed in output
* Whitespace around parentheses is allowed in output
* Any reasonable form of input/output is allowed
* No standard loopholes
* Shortest code in bytes for each language wins
  
[Answer]
# [J](http://jsoftware.com/), ~~23~~ 22 bytes
```
(];/:')'=;)&|._2{.\cut
```
[Try it online!](https://tio.run/##y/r/P81WT0Ej1lrfSl1T3dZaU61GL96oWi8mubTkf2pyRr5CmoK6kUKNnUJupVtpXnJJZn6ehqY6F0wqvyQjtSgNLgFSmJdajiqQlFgFYxRBGGn5@UBD/gMA)
```
                    cut    split by space
               _2{.\       only odds
             |.            reverse
   ;/:')'=;                join and sort by equality with ')'
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 8 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
ßN¶e╣╨j,
```
[Run and debug it](https://staxlang.xyz/#p=e14e1465b9d06a2c&i=2%7C%3EmyFunction%28%29%0Aotherfunction%28%29%7C%3Enewfunction%28%29%7C%3Ebaz%28%29%7C%3Ebar%28%29%7C%3Efoo%28%29&m=2)
## Explanation(unpacked)
```
.|>/kNas++
.|>/       split the string on "|>"
    k      reduce the list by:
     N     push the 2nd string with the last element popped, then push the last element
      a    put the previous iteration on top of the stack
       s   swap the bracket with the prev iteration
        ++ concatenate into one string
```
[Answer]
# Excel VBA (Immediate Window), ~~85~~ 75 bytes
*-10 bytes thanks to @TaylorScott*
```
For Each s In Split([A1],"|>"):o=IIf(o="",s,Left(s,len(s)-1)+o+")"):Next:?o
```
## Excel, ~~165~~ 154 bytes
*-11 bytes rethought the Excel based on changes to VBA*
```
=LET(x,FILTERXML("<a><b>"&SUBSTITUTE(A1,"|>","</b><b>")&"</b></a>","//b"),n,ROWS(x),a,n+1-SEQUENCE(n),CONCAT(INDEX(LEFT(x,LEN(x)-(a<n)),a),REPT(")",n-1)))
```
[Spreadsheet](https://1drv.ms/x/s!AkqhtBc2XEHJnA8jZJRpmljaGOAa?e=sxyeGS)
```
=LET(                                                 'define variables
                                                          return last parameter
    "<a><b>"&SUBSTITUTE(A1,"|>","</b><b>")&"</b></a>" 'Convert piped string to XML 
x,FILTERXML(                                  ,"//b") 'x = XML converted to array
n,ROWS(x)                                             'n = # rows in x
a,n+1-SEQUENCE(n)                                     'a = n .. 1
CONCAT(INDEX(LEFT(x,LEN(x)-(a<n)),a),REPT(")",n-1))   'final calculation
       INDEX(                    ,a)                  'x in reverse order
             LEFT(x,LEN(x)-(a<n))                     'if not first element delete 
                                                          rightmost char
                                     REPT(")",n-1)    'n-1 ")"
CONCAT(                                           )   'concatenate everything
```
## Original
```
=LET(s,SUBSTITUTE(A7,")",""),x,FILTERXML("<a><b>"&SUBSTITUTE(s,"|>","</b><b>")&"</b></a>","//b"),n,ROWS(x),CONCAT(INDEX(x,n+1-SEQUENCE(n)),REPT(")",LEN(A7)-LEN(s))))
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~11~~ 9 bytes
```
Ḳm2ɓṪṭ;µ/
```
[Try it online!](https://tio.run/##y0rNyan8///hjk25RicnP9y56uHOtdaHtur/P9yuGfn/v1J@SUZqUVppXnJJZn6ehqZCjZ1CXmo5qkBSYhWMUQRhpOXna2gq6SgoGYF4uZVucPVKAA "Jelly – Try It Online")
-2 bytes thanks to [Jonathan Allan](https://codegolf.stackexchange.com/users/53748/jonathan-allan)!
The `|>` must be surrounded by spaces
## How it works
```
Ḳm2ɓṪṭ;µ/ - Main link. Takes a string S on the left
Ḳ         - Split S on spaces
 m2       - Take every second element, ignoring the "|>" elements
   ɓ   µ  - Create a new dyadic chain f(a, b):
    Ṫ     -   Remove the trailing ")" from a and yield it
      ;   -   Concatenate the modified a and b
     ṭ    -    Tack the ")" to the end
        / - Reduce the split S by this. The ɓ in the chain tells
             the quick to reduce from the left with arguments reversed
```
[Answer]
# [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), ~~105~~ ~~98~~ ~~87~~ 78 bytes
```
	I =INPUT
S	I ARB . L '|>' ARB . F ')' REM . R =F L ')' R	:S(S)
	OUTPUT =I
END
```
[Try it online!](https://tio.run/##K87LT8rPMfn/n9NTwdbTLyA0hCsYyHQMclLQU/BRUK@xU4dy3BTUNdUVglx9gewgBVs3kCxIgNMqWCNYk4vTPzQEqBtoCJern8v//0Y1dk6OURqaICoIRLn5@2toAgA "SNOBOL4 (CSNOBOL4) – Try It Online")
Thanks to Razetime for -2 bytes.
### Explanation:
```
	I =INPUT	;* read input, assign to I
S			;* label S
	I [lhs] = [rhs]	;* replace the part of I matching the following pattern:	
	ARB . L '|>'	;* something followed by '|>' (assign to L)
	ARB . F ')'	;* followed by something followed by a ')' (assign to F)
	REM . R		;* and the rest of the string (assign to R)
			;* with:
	F L ')' R	;* F, L, ')', and R concatenated together
		:S(S)	;* on SUCCESS (a match was found), goto S
	OUTPUT =I	;* on FAILURE, proceed to output and end the program
END
```
[Answer]
# [Elixir](https://elixir-lang.org/), 64 bytes
```
&Macro.to_string Macro.expand Code.string_to_quoted!(&1),__ENV__
```
[Try it online!](https://tio.run/##VY29CsIwFIX3PsU1Q2mhBHTXRSo4qJuLSIjtjQ3Y3JomWMV3jy1Bwe07fxy86UHboGAZ0p2sLHFHondWmytEjUMnTQ1rqpHHQIyVuyeH9SxL53khRLk/ChFK41uOsmrgxBbwXkH73HhTOU0my1mRMHINWvWzporBx79xka8v2AiKaJyfiyTNtgfeedeD4tNxHj4 "Elixir – Try It Online")
Well, this looks a bit longish for a solution relying on built-in functionality, but I guess we need a "reference" implementation with Elixir doing it itself.
[Answer]
# [R](https://www.r-project.org/), ~~94~~ ~~92~~ 86 bytes
*Edit: -2 bytes thanks to Giuseppe*
```
function(s,t=el(strsplit(s,"[)]?(.>|$)")))Reduce(paste,c(rev(t),")"[+grepl("[(]",t)]))
```
[Try it online!](https://tio.run/##bY69CsJAEIT7PMZisYuHhX1i5wPYhkNi3Ggg3h17G//Iu5@RQFSwGr5ivhlJvQtt4Dw1vau19Q6j0Zw7jCoxdK2ODCXZDa6KYUFARDs@9jVjqKKyqVH4ikoGCMrlSTh0CCVaMEqWKPE9CMc4inPwembZz0M0FI5vP3yonlPIOxrvkSCbHuLHRFn2rV0PxeWxnS1/C@kF "R – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), ~~30~~ ~~23~~ 22 bytes
```
+`^(.+?).>(.+?\()
$2$1
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wXzshTkNP215Tzw5ExWhocqkYqRj@/29UY5db6Vaal1ySmZ8HFM0vyUgtSoPza@zyUsuRuUmJVRCqCESl5edraAIA "Retina 0.8.2 – Try It Online") Link includes test cases. Edit: Saved ~~7~~ 8 bytes thanks to @tsh. Explanation:
```
+`
```
Repeat until all pipes have been processed.
```
+`^(.+?).>(.+?\()
```
Match the first two terms up to the second term's opening bracket.
```
$2$1
```
Move the first term into the second term's argument.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 60 bytes
```
s=>s.match(/\w+\(?/g).reverse().join``+s.match(/\)/g).join``
```
[Try it online!](https://tio.run/##jZDBcsIgEIbvPsUeOgOMJnY8tkO8@QIea2dCcRNxEFIgWmt99pSIqbWnctmf/f/92GEr9sJLp5qQGbvGTlrjA3ir26CsAd55Xvh8J4Lc0OnqMF7R@bRmucM9Oo@U5VurTFmObxnW@6l7pUnh0QMHh@@tckhJ5UmPEOuF0rg8GkkfWR7sMjhl6sj0jVaBkpWJsZ1oqFYGgRfQ18HMiqspXN17sURko4XEuISf1hMghDH2PKqsA5o2eVGmacME8KNBGXD9CrZK6zE4jQBSyqFvdYgLD99AL2MRlRJWY65tTcuHU4qegQ4SOOc/eJgDkda5eCHwBOTgrKnJmZURde5m8FXA7rhojbw8wuD/J7ubnLGRDRt01Q0V0QYP94038TkIl0RlbRRZEn23j/ye@4PtT/cN "JavaScript (Node.js) – Try It Online")
This would fail if there were no pipes (not possible according to challenge rules) but here's an alternative version which can also handle that:
## [JavaScript (Node.js)](https://nodejs.org), 61 bytes
```
s=>(f=a=>a[1]?a.pop().slice(0,-1)+f(a)+')':a[0])(s.split`|>`)
```
[Try it online!](https://tio.run/##jZDPcsIgEMbvPsUeOgM7NfHP0Q7x5gt4VGdCkaR0ECiQWqs@e0qMtrWnctmP3W9/fMMrf@dBeOViZuxWtsKaECFY3URlDbA2sIJWjLOCryabOc@ddRTzoJWQdDzMJvhYUY6PBMmMr8YbpCEPTqtYnooSrzjBgwzAwMu3RnlJSRUI5l7y7UJpuTwYQceYR7uMXpm6w3cEStYm2XbcUa2MBFZAV2/DrLgOua@7WSoJ6TRPwUbrMKqHQAgiPg0q64H2SVbKuCYOQX44KaLcbsBWfTyE4wCgd3kZGh1T4Ns/0MtaQvUOq2WubU3Lh2NvPQO9SWCMfeNhDkRY79OFwAzI3ltTkzOWCXVup3AqYHdYNEZcHkH4/8nuNqc4sPFF@uoHldBG7u8bz/zzJnwvKmuTyHrRdTvL770/2O60Xw "JavaScript (Node.js) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 20 bytes
```
≔⪪Ｓ|>θ⭆⮌θ…ι⊖Ｌι⭆θ✂ι±¹
```
[Try it online!](https://tio.run/##ZYzBCsIwDIbvPsXYKYV58CwMZF4EFXFPUGvWFmraddlE2bvXzV0E/8vHny@JMjIqL11Ku66zmqAOzjIcKPRcc7SkQRRZPpb5hFZsV5dpxrCokwxwxQFjh9BOvnoph5XxAWyR7VFFfCAx3uGIpNmAFXP@f7RFVjurcD47o5aMsPlupuTZYGx6Umw9gRhLwudvvcn3gjij8R5EWg/uAw "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
≔⪪Ｓ|>θ
```
Split the input on `|>`.
```
⭆⮌θ…ι⊖Ｌι
```
Print the strings in reverse order without their last character.
```
⭆θ✂ι±¹
```
Print the last characters of the strings. This means that the first term gets reunited, while the remaining terms have their brackets moved to the end.
[Answer]
# [Python 2](https://docs.python.org/2/), 54 bytes
```
lambda s:reduce(lambda r,x:x[:-1]+r+')',s.split('|>'))
```
[Try it online!](https://tio.run/##TcnRCsIgFIDh@55idx7ZCrbuhLzsJSrCbcoEp3JUtoXvbkURXf18/H6Lk7NdUadrMWLuR1EFhnJMg4SvsVnZemH79lZjTShpwiF4oyOQzAmlZZm0kVXLPGobQQGK5a6tTxHo63bHzOftnOwQtbNAdy5OEtXPmVu5/LMXj0/wHeUc0Cc "Python 2 – Try It Online")
For each function going to left to right, insert the string `r` we have so far between the parens of the function `x`.
```
string |> new_function() = new_function(string)
```
This is done by removing the last character (a close paren), appending the string, then adding back the close paren. Because `reduce` starts the accumulator at the first element by default, we don't need any special handling if it's not a function.
This is longer in Python 3, which lacks `reduce` but can use a starred assignment to extract the initial value.
**Python 3, 59 bytes**
```
r,*l=input().split('|>')
for x in l:r=x[:-1]+r+')'
print(r)
```
[Try it online!](https://tio.run/##TcvBCgIhFEDRvV8hbvQ1FUztBsZlPxEtalAU7Ckvh3HCf7ciiFaXs7hpzS7isS3OB8P7wRQzKSFEo@0mjB7TnBXsHyn4rGTVEpiNxAv3yMNAYzkPu/7SUSdBskQesyJo7x/aoer7eppxyj6iAhazM2R/rhrN8s/b9fkNfWJjVPAC "Python 3 – Try It Online")
Alternatively:
**Python 3, 59 bytes**
```
r=''
for x in input().split('|>'):r=x[:-1]+r+x[-1]
print(r)
```
[Try it online!](https://tio.run/##TctBCsMgEIXhvacQN46EFtLuhGTZS4Qu2qAopKNMDTHFu1tLoRQefPyLF/fkAp7r5vxieK9NNjMIISoNUjIbiGfusS2uCdTxGRefQJZRKk1DnvShv3bU5anJInlMQKq2v6qnMj72y4pz8gFBsZCcIfvrMqLZ/vN@e32hDzYEUG8 "Python 3 – Try It Online")
[Answer]
# [Zsh](https://www.zsh.org/), 41 bytes
```
for a (${(s:|>:)1})x=${a//\()/($x)}
<<<$x
```
[Try it online!](https://tio.run/##qyrO@F@ekZmTqlCUmpiioFukYGidkq@g8T8tv0ghUUFDpVqj2KrGzkrTsFazwlalOlFfP0ZDU19DpUKzlsvGxkal4r8mUENe6n8jhRo7hdxKt9K85JLM/DwNTa78kozUojQ4HySfl1qOKpCUWAVjFEEYafn5QL0A "Zsh – Try It Online")
* `${1}` - take the input
* `(s:|>:)` - split on `|>`
* `for a ()` - for each element:
	+ `${a}` - take the element
	+ `///` - replace:
		- `\()` - empty parentheses
		- `($x)` - with the current value of `$x`, in more parentheses
	+ `x=` and assign that to `$x` (it starts as an empty string by default)
* `<<<$x` - print `$x`
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
Port of [FrownyFrog](https://codegolf.stackexchange.com/users/74681/frownyfrog)'s clever [J answer](https://codegolf.stackexchange.com/a/222594/53748)!
```
Ḳm2ṚF=Þ”)
```
A monadic Link accepting and yielding a list of characters (with the `|>` surrounded by a space on each side like the examples).
**[Try it online!](https://tio.run/##y0rNyan8///hjk25Rg93znKzPTzvUcNczf///@eXZKQWpZXmJZdk5udpaCrU2CnkpZajCiQlVsEYRRBGWn6@hiYA "Jelly – Try It Online")**
### How?
```
Ḳm2ṚF=Þ”) - Link: list of characters, S
Ḳ         - split at spaces
 m2       - modulo-2 slice [1st, 3rd, 5th, ...]
   Ṛ      - reverse
    F     - flatten
      Þ   - sort by:
     = ”) -   equals ')'?
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 90 bytes
```
f(s,l,t)char*s;{for(t=0;--l&&s[l-1]-62;t++);s=printf("%.*s",t+!l,s+l)-t||f(")",f(s,l-2));}
```
[Try it online!](https://tio.run/##TU/LbsMgEDyXr3CRGrEG@vChF@oc@xOWDy6CBIlABBtVje1vd3HcVj3NzuzuaEbLg9bLYlkWXiDo45DqrEYbE8P2WUnpd7vcefnSy9dGIeegcntOLqBl9OGxzlQgv/cicw8Sp6moQMXNTjYAal5OgwsMRrJaVzXqrm9HQptpf/p6vwSNLpY1FYRGPJpk/6RpH8znf/oxXDdIK9gYtzc0GX@xKGRWpKSvWIlYuVLBvWV3NdEy1PD0M95qgnKci/MFM6MUgNytJ53rRcbkTdhIqUDm5Rs "C (gcc) – Try It Online")
Expects no spacing.
[Answer]
# [V (vim)](https://github.com/DJMcMayhem/V), 11 bytes
```
òf|xxd0f(pò
```
[Try it online!](https://tio.run/##K/v///CmtJqKihSDNI2Cw5v@/88vyUgtik8rzUsuyczP09BUqLFTyEstRxNJSqyCMYogjLT8fA1NAA "V (vim) – Try It Online")
ò…ò repeats the commands until the first error, the rest are normal Vim commands.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 13 bytes
```
„|>¡Å»¨ì')«}θ
```
[Try it online!](https://tio.run/##yy9OTMpM/f//UcO8GrtDCw@3Htp9aMXhNeqah1bXntvx/39@SUZqUVppXnJJZn6ehmaNXV5qOTI3KbEKQhWBqLT8fA1NAA "05AB1E – Try It Online") The annoying thing here is `.»` only reduces by the first command after it, not a `}` or `]`-terminated function. And macros don't exist, so… ¯\\_(ツ)\_/¯
```
„|>¡Å»¨ì')«}θ  # full program
            θ  # last element of...
    Å»         # cumulatively reduced...
               # implicit input...
   ¡           # split by...
„|>            # literal...
     »         # to the right by...
        ')     # literal...
          «    # concatenated to...
      ¨        # all characters of...
               # (implicit) second element in current reduction step...
      ¨        # excluding the last...
       ì       # prepended to...
               # (implicit) first element in current reduction step
           }   # end cumulative reduce
               # implicit output
```
`')` can also be `Iθ`, `sθ`, or `¹θ`, `}` can also be `]`, and `θ` (only the one at the end) can be `¤` with no change in functionality.
[Answer]
# Java, ~~103~~ ~~84~~ ~~80~~ 77 bytes
```
s->{var p="";for(var c:s.split("\\|>"))p=c.replace("()","("+p+")");return p;}
```
*Saved 19 bytes thanks to [79037662](https://codegolf.stackexchange.com/users/89930).*
*Saved 4 bytes thanks to [pxeger](https://codegolf.stackexchange.com/users/97857).*
[Try it online!](https://tio.run/##jU@xTsMwFNzzFZYnm1IPjIRkZEMMFRNlcF27dXBs6/klKKT59uDQUnXkltPp7t7pNbKX62b/Ods2BkDSZC06tE6Yziu0wYu7sojdzllFlJMpkRdpPRlJQTIuRkKJmfpg96TNNtsgWH94/yASDomPv9kFb17C8Bo1SAzwdE7VxFRzWtdjL4HEitLSBGCLUI9JpOgsMrrdnmrKeayUAB2dVJpRxuk9ZXQVV5RTXoLGDjyJ5TT/zZXX4c2QULcidChiHkXnmREyRjcw@nCq2@H58m4@yvn/egGPGsy1d6q9/rqVO/l9JljIhHBzeyqm@Qc)
A positive lookahead can be used for a solution of the same length.
```
s->{var p="";for(var c:s.split("\\|>"))p=c.replaceAll("(?=\\))",p);return p;}
```
[Try it online!](https://tio.run/##jU@xTsMwFNzzFZYnG1EPjIQEsbAhhoqJMLip3To4tvX8EhSSfHtwaKk6csvpdHfv9BrZy02z/1xMGzwgaZIWHRordOdqNN6JmzwL3c6amtRWxkhepHFkJBlJOBsRJSbqvdmTNtlsi2Dc4f2DSDhEPv5mV7w5CcNrUCDRw8MpVRJdLHFTjr0EEgpKc@2BraK@jyIGa5DRqppKynkoagEqWFmrJ2sZZY9FVXFObwPPQWEHjoR8Xv7m8svwdoioWuE7FCGNonVMCxmCHRi9m8p2eD6/y3ia@V/P41GBvvSm0qmva7mT3yeClbT3V7fnbF5@AA)
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 49 bytes
```
f=a=>a.replace(/(.*).>(.*)./,(_,x,y)=>y+f(x)+')')
```
[Try it online!](https://tio.run/##XYxBDsIgEEX3XoQZizRxD0uvYUYErUGmoVSL6d1Ra2KMm//yk5d3oRsNNnV93kQ@ulq9Jm1IJdcHsg5aUGtUZtlWwl5OsqA2pfEwYSNQYLUcBw5OBT6BB7GdzbXsxmhzxxFeAq7@DM5nl/zXmE109997oMcH6Q3PvFTqEw "JavaScript (Node.js) – Try It Online")
Only works if no extra spaces are there.
---
# [JavaScript (Node.js)](https://nodejs.org), 50 bytes
```
a=>a.split`|>`.reduce((p,q)=>q.replace('(','('+p))
```
[Try it online!](https://tio.run/##XYxBDsIgFET3XoT/Y2XhHpaeo0hBMcinQGs03B1RE2NcTF5m8jIXtaqsk4tlF2gyzYqmhFQ8R@/KWOXIk5kWbQDiMKOQc@/Rqz4wYEPPNiI2TSGTN9zTCSywfZXX@2EJujgKgAxx82dQOZtkv0aVwdx@61E9PkgvWKL3S3sC "JavaScript (Node.js) – Try It Online")
This works if the input does not contais `"$"` character. Otherwise, `'('+` need to be replaced by `x=>x+` with +1 byte cost.
[Answer]
# [PowerShell Core](https://github.com/PowerShell/PowerShell), 81 bytes
```
-join($t=$args|% Sp* "|>"|% *m ')')[($l=$t.Count)..0]+")"*($l-!($t[0]|% e*h '('))
```
[Try it online!](https://tio.run/##TYtBDoIwFET3nKI21fbXQIx72Jh4AZeEBZJWMNBPSglR69lrDYlxNTMv80ZclJ1a1fdpg1YFpvNXSO/YGcFczmp7m/yWXEZJqC9orHIgHDiUgvU5c9kJZ@Mgyw7VngKVkaabaJaHKn6VbAkXHCC8k2THNKFHXwyP82wa16ERQFeKrlVW/6gvjFr@57V@rmG/oRGjGT4 "PowerShell Core – Try It Online")
Thanks to @Julian!
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 108 bytes
```
param($s)$n=$s.split("|>");$k=(($n|%{$n[--$q]})|%{$_-replace"\)$"})-join"";$k+")"*($k-replace"[^\(]").length
```
[Try it online!](https://tio.run/##TcrxCoIwEIDxdzkuvCvmC4S@iFksmWmu29oMofTZVxJEf3384PNuMiF2xtqUvA76RhgZpcCYR2/7kWAugfc4FEQo8@aFUimF93rhFScVjLe6MXBghIXV1fUC8Pl3wLAlHH5DdTxQDZxbI5exSyllbuxMaB/SjL0T4rkUM/3zrJ/fhDWtc8TZGw "PowerShell – Try It Online")
* Take a string
* Split it by `|>`
* Save ^ to an array
* Reverse the array
* Loop on each element
* Remove trailing `)`
* Join array
* Append number of `(` in the joined string amount `)`
* Print and bye bye!
[Answer]
# [Red](http://www.red-lang.org), 85 bytes
```
func[s][t: take s: split s"|>"forall s[t: rejoin[replace s/1"()"""mold to-paren t]]t]
```
[Try it online!](https://tio.run/##TY2xDsIwDER3vsLy1A4IwdihIx/AGmUIrSMCaRw5RgjUfw@tkCqm0@ne3QmN9UKjsTvfQfXPNJhijXag7kFQOig5BoWCc4@excUIZY2F7hySEcrRDQt4OGLTIuLEcQTlfXZCCdRatTVLSAoekPVGsn5o4NS0c5/o9W@v7vMTWcUzL5O7rX2a@@l93nCsXw "Red – Try It Online")
[Answer]
# [PowerShell Core](https://github.com/PowerShell/PowerShell), ~~67~~ ~~57~~ ~~45~~ 44 bytes
```
$args-split'.>'|%{$r=$_|% rep* '(' "($r"}
$r
```
[Try it online!](https://tio.run/##XU1NT4NAEL3vr5g0g7sY8NA7pImJV409GtO062BrKIuzS6qy/HZkoVbSd3mZ9zW1ORHbPZVlqg1Tj0XW9rjld5vaujw4eZdLH7XIGW58BEz1LUglYaGQF51A7jshVkqIRMmlz4/fD02l3cFUKpYJyNm9jGUcUsbtiYtLyucVnebnbvszEQcqjAlLMnCQgjsvXK0FDG9EDB4iaAUMQPqqORmJtKM3yAA3k8Nkm9INwg0WU27UX57W94115vi4@xgqr6tpKGDdaE3Who1zOaXP/@1L7vlv@RwbjU50/S8 "PowerShell Core – Try It Online")
The `rep*` is the shortcut for the `replace` method.
[Answer]
# [Python 3](https://docs.python.org/3/), 84 79 bytes
```
import re;r=re.findall;i=input()
print(''.join(r('[\w(]+',i)[::-1]+r('\)*',i)))
```
[Try it online!](https://tio.run/##VcjBCsIwDADQu1/RWxOnA/G2MX9kGzK1ZZGZlJAxFP@9KuLB2@Olu43C@5zplkTNaai10VBG4sswTTU1xGk2wFVSYgPvy6sQg4JvuwX6wm8I26ra7vrifR2uP4GYs9gY9BhnPhsJA7rnwXFY/uM0PH7QL6II4As "Python 3 – Try It Online")
* Seems to be a complete solution: works whether there are spaces around the functions/constants/pipes or not, works whether first position contains constant or function.
* Doesn't technically look for pipes, so you could replace |> with |< and it would return the same output. Could add a positive lookforward to the regex but that would eat another ~10 bytes and the contest didn't specify.
* Pays a 27-byte 22-byte penalty just for importing one regex method. Thanks Python.
* Edited for small improvement.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~15~~ 12 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
q"|>" rÏiXJÉ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=cSJ8PiIgcs9pWErJ&input=WyJvdGhlcmZ1bmN0aW9uKCkgfD4gbmV3ZnVuY3Rpb24oKSB8PiBiYXooKSB8PiBiYXIoKSB8PiBmb28oKSIsIjIgfD4gbXlGdW5jdGlvbigpIl0KLW0tUQo)
* saved 3 by assuming no whitespaces as suggested by OP @79037662
```
 q"|>"    - split on pipe
 r        - reduce by
 ÏiXJÉ    - inserting before )
```
[Answer]
# [Python 3](https://docs.python.org/3/), 70 bytes
```
*a,b=input().split("|>")[::-1]
print(*[f[:-1]for f in a],b,")"*len(a))
```
The program first `split`s the `input` into a list using the pipe operator, `"|>"`, as the separator. Using multiple assignment, `b` is set equal to the last element of the list (previously the first element prior to being reversed). `b` contains a string of the first element in the pipe, which may or may not be a function. The rest of the list is assigned to `a`. All of the elements of `a` are strings of functions. Next, the program outputs all the elements of `a` with `)` removed from each, `b`, and `")"*len(a)`.
[Try it online!](https://tio.run/##TcfBCsMgDADQ@75CPCXiCmO3wvoj0oMWQ4WSiEsZG/13R9llp8erb12F77276NOjcN0VcHjWrSjYY7IYxvF6my@1FVZwgcJZkmbIFDZx9slbtG7LDBGxd9E1N9p50SIMeEycX/9N8fOjnZAI4Bc "Python 3 – Try It Online")
If we're allowed to require that only the first item in the pipe has a space after it, but none of others, we can save **1 byte**.
# 69 bytes
```
a=input().split("|>")[::-1]
print(*[f[:-1]for f in a],")"*(len(a)-1))
```
[Try it online!](https://tio.run/##RcfBCsIwDADQu19RekqGE4a3gf2RskPVBQMlKTVDlP57ZXjw9HjlbQ@Vc@/pwlI2Azw9S2YD34LHOM/jtBxKZTEYIsW9pNWRY3FpOXr0A@RVIOE4Ifau@U6b3IxVAF0Lsr7@b@GaPj/qDqkCfgE "Python 3 – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 13 bytes
```
.UXtlZZbcQ"|>
```
[Test suite](http://pythtemp.herokuapp.com/?code=.UXtlZZbcQ%22%7C%3E&test_suite=1&test_suite_input=%222%7C%3EmyFunction%28%29%22%0A%22other_function%28%29%7C%3Enew_function%28%29%7C%3Ebaz%28%29%7C%3Ebar%28%29%7C%3Efoo%28%29%22&debug=0)
---
Explanation:
```
.U      cQ"|> | Reduce the input split at "|>" on the following lambda, where b is the current value and Z is the next item:
  XtlZZb      |  Insert b into Z at index len(Z)-1
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 42 bytes
```
#//.{a__,"|",_,b__,"(",c___}:>{b,"(",a,c}&
```
[Try it online!](https://tio.run/##TY3BCsIwEETv@YwNlArRgkfRUBA8Cx5Flm1IaA9NII2Ipumvx1ZBPL15A8P0FFrdU@gUZXPIvKo2kRAFjCBQNEsqQShETDsZm4@RUKnIZ9/ZcOVrCbCXpj625EkF7Yea34rposhOkcF2lP3zdLcqdM6WKxAM3Pzoza8apdWPf23o9YVfYJybZyzlNw "Wolfram Language (Mathematica) – Try It Online")
Takes and returns a list of characters. Requires no spacing.
[Answer]
# [Twue](https://github.com/ConorOBrien-Foxx/Twue/), 123 bytes
```
@::>*
^()::=()!
^_ ::=_ !
^_::=_^
!()::=!
!_::=_!
$!::=$;
 |> $;::= $#(;%
##_::~_
 $#::= $##
 $::=$
_$::=$#_
%::~)
::=
^ @$
```
[Try it on the website!](https://conorobrien-foxx.github.io/Twue/?code=%40%3A%3A%3E*%0A%5E()%3A%3A%3D()!%0A%5E_%20%3A%3A%3D_%20!%0A%5E_%3A%3A%3D_%5E%0A!()%3A%3A%3D!%0A!_%3A%3A%3D_!%0A%24!%3A%3A%3D%24%3B%0A%20%7C%3E%20%24%3B%3A%3A%3D%20%24%23(%3B%25%0A%23%23_%3A%3A%7E_%0A%20%24%23%3A%3A%3D%20%24%23%23%0A%20%24%3A%3A%3D%24%0A_%24%3A%3A%3D%24%23_%0A%25%3A%3A%7E)%0A%3A%3A%3D%0A%5E%20%40%24,input=1337%20%7C%3E%20a()%20%7C%3E%20b())
[![animation of the code running successfully](https://i.stack.imgur.com/WMIMz.gif)](https://i.stack.imgur.com/WMIMz.gif)
---
Twue is a spiritual successor to [Thue](https://esolangs.org/wiki/Thue) I made. I initially tried answering this challenge in Thue, and had to manually describe moving each character one byte to the left, individually, so the byte count came out to ~1kb. Then, I realize I didn't properly handle constants and abandoned the code, not wanting to rewrite that mess from scratch. Enter Twue, which allows wildcards to be used (`_`) to refer to generic characters. Furthermore, it removes the random rule selection from the language, and creates a better standard for input/output.
The language is still a bit of a work in progress, but most of the bugs have been ironed out, and most of the spec has been implemented.
## Explanation
```
@::>*
```
This replaces all `@` in the workspace with a line of input. Basically: readline. For an input of `1234 |> foo() |> bar()`, this populates the workspace with:
```
^ 1234 |> foo() |> bar()$
```
`^` and `$` are characters we'll be using as pointers, of sorts, for iterating forward and backward through the code.
```
^()::=()!
^_ ::=_ !
^_::=_^
```
This section moves the `^` pointer after the first expression, which may or may not contain parentheses. We want to preserve these. This inserts `!` after the first expression, and we are ready to parse.
```
!()::=!
!_::=_!
$!::=$;!
```
Now, for every expression afterwards, we want to strip the `()` from it. So, we move `!` character by character through the input, removing `()` in front of it as we go. After these steps, the input will look like this:
```
 1234 |> foo |> bar$;!
```
Now we are ready for the second stage of parsing. We will use `!` later in the final stages of printing. Now, we have two pointers, `$` and `;`, which will define the range we're operating on.
```
 |> $;::= $#(;%
##_::~_
 $#::= $##
 $::=$
_$::=$#_
```
`_$::=$#_` simply moves every character in front of a `$` after it, prepending a `#` to it. This signifies we want to print that character. We repeat this until the `$` pointer is at the leftmost part of the word, after a space. Since we are at the beginning of the word, we start printing the characters after `$#`, by first duplicating the `#`, and printing the character after `#__`. This allows us to only print when we want to—if we didn't duplicate, we'd print the strings in reverse, or lose track of the `$` pointer. If we find the string `|> $;`, we've printed all the characters we could, and we still have more things to parse. We remove the `|>` and append a `%`, signifying we need to print a corresponding closing parenthesis.
These replacements repeat until they can't anymore.
```
%::~)
```
If there are no other substitutions we can possibly make, we simply take each `%` and output a corresponding `)`.
]