#process.Pid to String?

1 messages · Page 1 of 1 (latest)

summer arch
#

Hi, is there any function that does the conversion? I am just playing around the process library, and want to store and parse a pid. It may not be very practical but curious if there is a good known way.

inner steeple
#

You can turn anything into a string with string.inspect. I don't think there's anything for parsing a PID, though.

#

Wild guess: You might want to look into named processes.

boreal jacinth
#

Note the format isn’t stable so it’s not suitable for parsing

#

There isn’t anything you can practically do by parsing a pid

dry solar
#

I was using that one for a BEAM inspector / debugging type tool

summer arch
#

Right, not so practical but it was just out of curiosity.

summer arch
#

I was practicing Gleam, and found a challenge for my self - how can I parse the PID info?

The process.self spits out something like this: //erl(<0.89.0>)
If I can take off the brackets and filter out the numbers within a list, and check if there are 3 elements. That would be a good small puzzle for me.

This is purely my learning purpose, so the code is not the most efficient. Any suggestion would be appreciated, but the string.inspect is the one I was looking for.

dry solar
#

If you really want to just parse that inspect representation into a list for fun/learning, I'd just do it like so:

  input
  |> string.drop_start(7)
  |> string.drop_end(2)
  |> string.split(".")

should give you the same

summer arch
#

Oh, that makes sense. We can just ignore the first 7 and last 2 from the original string.
Discord is new to me. I should also learn how to format a code snippet in the chat as well 😅

#

io.println("hello")

#
io.println("hello")
dry solar
#

you can do

to get the rust syntax highlighting, which is close enough to gleam
boreal jacinth