Code not working #4937
Replies: 3 comments
-
Hello! Welcome to Gleam! I'm afraid I don't know what the problem is with your code (you may have more luck getting help in the discord chat server's "questions" channel). It's rather challenging to know what the problem is because this is quite a lot of code, yet some of the code is missing, and you've not shared the output including any errors that occur. The best way to get help is to produce the smallest amount of code that fully reproduces the behaviour you're confused with, and to share the unexpected output. That way people can understand and debug without having to do lots of extra work, so they'll be more able to help you. For trickier problems if you can share the reproduction as a git repo that folks can download and run that is especially helpful, as otherwise they'll have to try and manually recreate your project to debug it. Misc code feedbackI wanted to point out that your "supervisor" code isn't a supervisor! A supervisor is a specific thing in OTP, it's a special process that starts other children, monitors them, traps their exits and restarts the children according to a specified strategy when they exit. This is almost always done using Erlang's You may also want to rename your |
Beta Was this translation helpful? Give feedback.
-
Thanks for pointing some things out @lpil. Regarding the supervisor, earlier I was using a The main issue is inside let sqrt_value: Float = case int.square_root(squares_sum) {
Ok(value) -> value
Error(_) -> -1.0
} I have been stuck with this for a while. Any help would be much appreciated. |
Beta Was this translation helpful? Give feedback.
-
Found the main issue which was due to improper handling of processes. When spawning multiple actors, the program was not waiting for all of them to finish, it spawned them and exited immediately. I added a mechanism to wait until all actors complete their work concurrently. You can check out my solution here: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I am new to Gleam and experimenting with the actors. For some weird reason the block inside
list.each
inside worker'shandle_message
is not being computed. Especially when computingsum_of_squares
, the subsequent lines are not being reached.If someone could take a look at this, that would be really helpful. Thanks in advance :)
Following is my code for ref:
Supervisor
Worker
Beta Was this translation helpful? Give feedback.
All reactions