Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

71%
+3 −0
Challenges Weave Strings Together

Haskell, 40 bytes f((h:t):r)=h:f(r++[t]) f(_:r)=f r f _=[] Try it online!

posted 4y ago by xnor‭  ·  edited 4y ago by xnor‭

Answer
#8: Post edited by user avatar xnor‭ · 2020-11-24T08:04:40Z (about 4 years ago)
  • # [Haskell], 40 bytes
  • ```haskell
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • ```
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • (Dunno what's going on with the syntax highlighting)
  • # [Haskell], 40 bytes
  • ```haskell
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • ```
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
#7: Post edited by user avatar Razetime‭ · 2020-11-24T08:04:26Z (about 4 years ago)
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-hs -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • (Dunno what's going on with the syntax highlighting)
  • # [Haskell], 40 bytes
  • ```haskell
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • ```
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • (Dunno what's going on with the syntax highlighting)
#6: Post edited by user avatar xnor‭ · 2020-11-23T07:44:05Z (about 4 years ago)
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-hs -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-hs -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • (Dunno what's going on with the syntax highlighting)
#5: Post edited by user avatar xnor‭ · 2020-11-23T07:43:32Z (about 4 years ago)
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-python -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-hs -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
#4: Post edited by user avatar xnor‭ · 2020-11-23T07:43:24Z (about 4 years ago)
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-none -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-python -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
#3: Post edited by user avatar xnor‭ · 2020-11-23T07:43:13Z (about 4 years ago)
  • # [Haskell], 40 bytes
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-none -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
#2: Post edited by user avatar xnor‭ · 2020-11-23T07:42:41Z (about 4 years ago)
  • # [Haskell], 40 bytes
  • <!-- language-all: lang-hs -->
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
  • # [Haskell], 40 bytes
  • f((h:t):r)=h:f(r++[t])
  • f(_:r)=f r
  • f _=[]
  • [Try it online!][TIO-khu8sfl0]
  • [Haskell]: https://www.haskell.org/
  • [TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"
#1: Initial revision by user avatar xnor‭ · 2020-11-23T07:42:21Z (about 4 years ago)
# [Haskell], 40 bytes

<!-- language-all: lang-hs -->

    f((h:t):r)=h:f(r++[t])
    f(_:r)=f r
    f _=[]

[Try it online!][TIO-khu8sfl0]

[Haskell]: https://www.haskell.org/
[TIO-khu8sfl0]: https://tio.run/##JY7BCsIwEETv/YoleGix/kChB1HBg6IHbyGUJU2aYJqENIr@vDFtYQ/zZgZ2FE5PYUxKsixVE6smVK1qZBm2WxpZVciymy0JoZDQtZSlKKY4QQuUkqe2jtSEaytGzGJ0by0IqynhrhfZGJyRC591pnwPJcLaOH28QYtRO7vw8YvGDbC/X3Lt8DJRv9ewJrfAFYaeMFYUI2qbn4/or@CDthE2M4CEZVf6cWlwmNKOe/8H "Haskell – Try It Online"