Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1006173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:24:57+00:00 2026-05-16T08:24:57+00:00

Hi this is my first post here hope you all are well. So Im

  • 0

Hi this is my first post here hope you all are well. So Im just starting erlang and I ran into a problem im not sure how to tackle yet.

So I have a binary I am recieving in the form of

<<56, 23, 67, 34, 45, 78, 01, 54, 67, 87, 45, 53, 01, 34, 56, 78>>

My goal is to split it into a sub list (or binary if more efficient) based on the 01.

For example the above should come out looking like:

<<56, 23, 67, 34, 45, 78>> <<54, 67, 87, 45, 53>> <<34, 56, 78>>

-or-

[[56, 23, 67, 34, 45, 78], [54, 67, 87, 45, 53], [34, 56, 78]]

The 01 is the separating tag, it does not need to be included in the final output.

I have tried something as such: (PLEASE disregard if there is a better way)

parse1([]) -> [];
parse1(1) -> io:format("SOHSOHSOHSOHSOHSSOHSOHS");
parse1(Reply) -> parse1({Reply, []});
parse1({Reply, nxtParse}) ->
    [H | T] = Reply,
    case H of
         _ when H > 1 ->
            [H | nxtParse],
              io:format("Reply 1 = ~p~n", [H]),
            parse1({T, nxtParse});
         _ when H == 1 -> 
            io:format("SOHSOHSOHSOHSOHSSOHSOHS");

        [] ->
            ok

    end.

This isn’t really clean at all and doesn’t resemble at all what pro’s write. Im sure Ill smack my head “duh” when someone clues me in.

I realize there is definitely more than one solution, but what is the BEST one. It seems ERL has so many BIF’s and way to do things, just gotta find my way around I guess.

Thanks for the help guys
-B

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:24:58+00:00Added an answer on May 16, 2026 at 8:24 am

    Coming with R14A, Erlang now includes a binary module to handle such tasks:

    1> Bin = <<56, 23, 67, 34, 45, 78, 01, 54, 67, 87, 45, 53, 01, 34, 56, 78>>.
    <<56,23,67,34,45,78,1,54,67,87,45,53,1,34,56,78>>
    2> binary:split(Bin, <<01>>, [global]).
    [<<56,23,67,34,45,78>>,<<"6CW-5">>,<<"\"8N">>]
    

    Note that although it looks wrong (<<"6CW-5">> and <<"\"8N">>), the underlying representation is right and the strings are the VM trying to figure out how to print out the binaries. See the same call when outputting in a raw format:

    3> io:format("~w~n", [binary:split(Bin, <<01>>, [global])]).
    [<<56,23,67,34,45,78>>,<<54,67,87,45,53>>,<<34,56,78>>]
    ok
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first post here so I hope I provide all the right
My first post here, so i hope this is the right area. I am
This is my first time here so I hope I post this question at
This is my first post here. I have a problem. I need to take
um, first post here, this place seems to be all over google and i
Usless Background Info Hello, all. This is my first post here, but I often
this is my first post on stackoverflow. I hope my question is not to
This is my first post on SO, so be gentle. I'm not even sure
this is my first time to post here. I have a problem on my
This is my first post here and I hope that someone will be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.