Post History
Haskell, 52 48 45 42 bytes Caught mistake thanks to rak1507 Saved 3 bytes thanks to Hakerh400 f n=n:g[n-1,n-2..1] g(b:c:t)=c:b:g t g t=t Try it online! g takes the rest of the trains. -...
Answer
#7: Post edited
# [Haskell], <s>52</s> <s>48</s> 45 bytes- Caught mistake thanks to rak1507
- <!-- language-all: lang-hs -->
- f n=n:g[n-1,n-2..1]
g(b:c:t)=[c,b]++g t- g t=t
[Try it online!][TIO-kpop5lec]- [Haskell]: https://www.haskell.org/
[TIO-kpop5lec]: https://tio.run/##y0gszk7Nyfn/P00hzzbPKj06T9dQJ0/XSE/PMJYrXSPJKtmqRNM2OlknKVZbO12hhAuIbUv@5yZm5ilYWSl4@itoaHKBebYKKflcCgq5iQW@8QoFRZl5JQoqIJ5CmkK0IdA4g9j/AA "Haskell – Try It Online"- `g` takes the rest of the trains.
- ```
- -- This is a fork, so append c (monad) and b (dyad)
- -- and continue with the rest of the train
- g(b:c:t)#=[c,b]++g t
- -- t is either empty or a single monad, so finish it off
- g t=t
- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
- f n=n:g[n-1,n-2..1]
- ```
- # [Haskell], <s>52</s> <s>48</s> <s>45</s> 42 bytes
- Caught mistake thanks to rak1507
- Saved 3 bytes thanks to Hakerh400
- <!-- language-all: lang-hs -->
- f n=n:g[n-1,n-2..1]
- g(b:c:t)=c:b:g t
- g t=t
- [Try it online!][TIO-kpq203v9]
- [Haskell]: https://www.haskell.org/
- [TIO-kpq203v9]: https://tio.run/##y0gszk7Nyfn/P00hzzbPKj06T9dQJ0/XSE/PMJYrXSPJKtmqRNM22SrJKl2hhAuIbUv@5yZm5ilYWSl4@itoaHKBebYKKflcCgq5iQW@8QoFRZl5JQoqIJ5CmkK0IdAsg9j/AA "Haskell – Try It Online"
- `g` takes the rest of the trains.
- ```
- -- This is a fork, so append c (monad) and b (dyad)
- -- and continue with the rest of the train
- g(b:c:t)#=[c,b]++g t
- -- t is either empty or a single monad, so finish it off
- g t=t
- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
- f n=n:g[n-1,n-2..1]
- ```
#6: Post edited
# [Haskell], <s>52</s> 48 bytes- Caught mistake thanks to rak1507
- <!-- language-all: lang-hs -->
f n=[n]++g[n-1,n-2..1]- g(b:c:t)=[c,b]++g t
- g t=t
[Try it online!][TIO-kpo1lt1b]- [Haskell]: https://www.haskell.org/
[TIO-kpo1lt1b]: https://tio.run/##HYw5CoAwFAX7nOIVFgkuGMtADmAhHiAEibuoX9HcPy7FFMPAzO5eh20LYQRpQzaOJ0OpTCgtskxaNvFWdcoLbbqk/So8e9E@7G4hKIWyBhfsN43@YMDuzqrBeS3kEX2GEUa@u9yGBw "Haskell – Try It Online"- `g` takes the rest of the trains.
- ```
- -- This is a fork, so append c (monad) and b (dyad)
- -- and continue with the rest of the train
- g(b:c:t)#=[c,b]++g t
- -- t is either empty or a single monad, so finish it off
- g t=t
- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
f n=[n]++g[n-1,n-2..1]- ```
- # [Haskell], <s>52</s> <s>48</s> 45 bytes
- Caught mistake thanks to rak1507
- <!-- language-all: lang-hs -->
- f n=n:g[n-1,n-2..1]
- g(b:c:t)=[c,b]++g t
- g t=t
- [Try it online!][TIO-kpop5lec]
- [Haskell]: https://www.haskell.org/
- [TIO-kpop5lec]: https://tio.run/##y0gszk7Nyfn/P00hzzbPKj06T9dQJ0/XSE/PMJYrXSPJKtmqRNM2OlknKVZbO12hhAuIbUv@5yZm5ilYWSl4@itoaHKBebYKKflcCgq5iQW@8QoFRZl5JQoqIJ5CmkK0IdA4g9j/AA "Haskell – Try It Online"
- `g` takes the rest of the trains.
- ```
- -- This is a fork, so append c (monad) and b (dyad)
- -- and continue with the rest of the train
- g(b:c:t)#=[c,b]++g t
- -- t is either empty or a single monad, so finish it off
- g t=t
- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
- f n=n:g[n-1,n-2..1]
- ```
#5: Post edited
- # [Haskell], <s>52</s> 48 bytes
- Caught mistake thanks to rak1507
- <!-- language-all: lang-hs -->
- f n=[n]++g[n-1,n-2..1]
- g(b:c:t)=[c,b]++g t
- g t=t
- [Try it online!][TIO-kpo1lt1b]
- [Haskell]: https://www.haskell.org/
- [TIO-kpo1lt1b]: https://tio.run/##HYw5CoAwFAX7nOIVFgkuGMtADmAhHiAEibuoX9HcPy7FFMPAzO5eh20LYQRpQzaOJ0OpTCgtskxaNvFWdcoLbbqk/So8e9E@7G4hKIWyBhfsN43@YMDuzqrBeS3kEX2GEUa@u9yGBw "Haskell – Try It Online"
- `g` takes the rest of the trains.
- ```
- --- This is a dyadic train, so append c (monad) and b (dyad)
- -- and continue with the rest of the train
- g(b:c:t)#=[c,b]++g t
- -- t is either empty or a single monad, so finish it off
- g t=t
- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
- f n=[n]++g[n-1,n-2..1]
- ```
- # [Haskell], <s>52</s> 48 bytes
- Caught mistake thanks to rak1507
- <!-- language-all: lang-hs -->
- f n=[n]++g[n-1,n-2..1]
- g(b:c:t)=[c,b]++g t
- g t=t
- [Try it online!][TIO-kpo1lt1b]
- [Haskell]: https://www.haskell.org/
- [TIO-kpo1lt1b]: https://tio.run/##HYw5CoAwFAX7nOIVFgkuGMtADmAhHiAEibuoX9HcPy7FFMPAzO5eh20LYQRpQzaOJ0OpTCgtskxaNvFWdcoLbbqk/So8e9E@7G4hKIWyBhfsN43@YMDuzqrBeS3kEX2GEUa@u9yGBw "Haskell – Try It Online"
- `g` takes the rest of the trains.
- ```
- --- This is a dyadic train, so append c (monad) and b (dyad)
- -- This is a fork, so append c (monad) and b (dyad)
- -- and continue with the rest of the train
- g(b:c:t)#=[c,b]++g t
- -- t is either empty or a single monad, so finish it off
- g t=t
- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
- f n=[n]++g[n-1,n-2..1]
- ```
#4: Post edited
# [Haskell], 50 bytes- <!-- language-all: lang-hs -->
f n=[n-1,n-2..1]#[n](b:c:t)#a=t#a++[c,b]t#a=a++t[Try it online!][TIO-kpn9kiha]- [Haskell]: https://www.haskell.org/
[TIO-kpn9kiha]: https://tio.run/##y0gszk7Nyfn/P00hzzY6T9dQJ0/XSE/PMFY5Oi@WSyPJKtmqRFM50bZEOVFbOzpZJymWC8i0BXJK/ucmZuYpWFkpePoraGhygXm2Cin5XAoKuYkFvvEKBUWZeSUKKiCeQppCtCHQWIPY/wA "Haskell – Try It Online"`#` takes a list of numbers representing a previously processed sub-train on the right, and the rest of the trains on the left.- ```
- --- This is a dyadic train, so appending c (monad) and b (dyad)
- -- and continue with the rest of the train
(b:c:t)#a=t#a++[c,b]- -- t is either empty or a single monad, so finish it off
t#a=a++t- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
f n=[n-1,n-2..1]#[n]- ```
- # [Haskell], <s>52</s> 48 bytes
- Caught mistake thanks to rak1507
- <!-- language-all: lang-hs -->
- f n=[n]++g[n-1,n-2..1]
- g(b:c:t)=[c,b]++g t
- g t=t
- [Try it online!][TIO-kpo1lt1b]
- [Haskell]: https://www.haskell.org/
- [TIO-kpo1lt1b]: https://tio.run/##HYw5CoAwFAX7nOIVFgkuGMtADmAhHiAEibuoX9HcPy7FFMPAzO5eh20LYQRpQzaOJ0OpTCgtskxaNvFWdcoLbbqk/So8e9E@7G4hKIWyBhfsN43@YMDuzqrBeS3kEX2GEUa@u9yGBw "Haskell – Try It Online"
- `g` takes the rest of the trains.
- ```
- --- This is a dyadic train, so appending c (monad) and b (dyad)
- -- This is a dyadic train, so append c (monad) and b (dyad)
- -- and continue with the rest of the train
- g(b:c:t)#=[c,b]++g t
- -- t is either empty or a single monad, so finish it off
- g t=t
- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
- f n=[n]++g[n-1,n-2..1]
- ```
#3: Post edited
- # [Haskell], 50 bytes
- <!-- language-all: lang-hs -->
- f n=[n-1,n-2..1]#[n]
- (b:c:t)#a=t#a++[c,b]
- t#a=a++t
- [Try it online!][TIO-kpn9kiha]
- [Haskell]: https://www.haskell.org/
[TIO-kpn9kiha]: https://tio.run/##y0gszk7Nyfn/P00hzzY6T9dQJ0/XSE/PMFY5Oi@WSyPJKtmqRFM50bZEOVFbOzpZJymWC8i0BXJK/ucmZuYpWFkpePoraGhygXm2Cin5XAoKuYkFvvEKBUWZeSUKKiCeQppCtCHQWIPY/wA "Haskell – Try It Online"
- # [Haskell], 50 bytes
- <!-- language-all: lang-hs -->
- f n=[n-1,n-2..1]#[n]
- (b:c:t)#a=t#a++[c,b]
- t#a=a++t
- [Try it online!][TIO-kpn9kiha]
- [Haskell]: https://www.haskell.org/
- [TIO-kpn9kiha]: https://tio.run/##y0gszk7Nyfn/P00hzzY6T9dQJ0/XSE/PMFY5Oi@WSyPJKtmqRFM50bZEOVFbOzpZJymWC8i0BXJK/ucmZuYpWFkpePoraGhygXm2Cin5XAoKuYkFvvEKBUWZeSUKKiCeQppCtCHQWIPY/wA "Haskell – Try It Online"
- `#` takes a list of numbers representing a previously processed sub-train on the right, and the rest of the trains on the left.
- ```
- -- This is a dyadic train, so appending c (monad) and b (dyad)
- -- and continue with the rest of the train
- (b:c:t)#a=t#a++[c,b]
- -- t is either empty or a single monad, so finish it off
- t#a=a++t
- ```
- `f` simply starts it off with the last function `n` and the other trains `1..n-1` (in reverse).
- ```
- f n=[n-1,n-2..1]#[n]
- ```
#1: Initial revision
# [Haskell], 50 bytes <!-- language-all: lang-hs --> f n=[n-1,n-2..1]#[n] (b:c:t)#a=t#a++[c,b] t#a=a++t [Try it online!][TIO-kpn9kiha] [Haskell]: https://www.haskell.org/ [TIO-kpn9kiha]: https://tio.run/##y0gszk7Nyfn/P00hzzY6T9dQJ0/XSE/PMFY5Oi@WSyPJKtmqRFM50bZEOVFbOzpZJymWC8i0BXJK/ucmZuYpWFkpePoraGhygXm2Cin5XAoKuYkFvvEKBUWZeSUKKiCeQppCtCHQWIPY/wA "Haskell – Try It Online"