
mvellandi
Exploring Graphs with Elixir: Out of scope variable won't print (105, 107)
Exploring Graphs with Elixir by @tonyhammond: P.105, 107 — Ch 3 > Visualizing Graphs > Rendering with Graphviz
In making the water molecule and after writing a graph file using a variable, we’re told in 2 examples to print out the variable to inspect it using IO.puts
iex> with {:ok, dot} = Graph.to_dot(g) do
...> write_graph(dot, "dot/h2o.dot")
...> end
#GraphCommons.Graph<type: native, file: "...", data: "strict graph {\n...">
iex> IO.puts dot
strict graph {
"O"
"H"
"H"
"H" -- "O" [weight=1]
"H" -- "O" [weight=1]
}
:ok
Maybe it’s just me, but this produces a function dot/0 not found error.
The variable “dot” is probably no longer in scope after having performed the first operation.
To make it print, I moved the print command above write_graph/2 command like so:
iex> with {:ok, dot} = Graph.to_dot(g) do
...> IO.puts dot
...> write_graph(dot, "dot/h2o.dot")
...> end
(graph output...)
#GraphCommons.Graph<type: native, file: "...", data: "strict graph {\n...">
Marked As Solved

tonyhammond
Author of Exploring Graphs with Elixir
Thanks for the catch.
I fixed this by reading it back in from the file store, as so:
iex> IO.puts read_graph(“dot/default.dot”).data
In two places.
Should be in the next beta.
Popular Pragmatic Bookshelf topics

page 20: … protoc command…
I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New

This test is broken right out of the box…
— FAIL: TestAgent (7.82s)
agent_test.go:77:
Error Trace: agent_test.go:77
agent_test.go:...
New

Title: Web Development with Clojure, Third Edition - migrations/create not working: p159
When I execute the command:
user=> (create-...
New

I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here.
...
New

In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions:
In Gemfile, change
gem 'rails'
t...
New

Dear Sophie.
I tried to do the “Authorization” exercise and have two questions:
When trying to plug in an email-service, I found the ...
New

Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New

The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error.
lib/pento_web/live/product_l...
New

Title: Agile Web Development with Rails 7: (page 70)
I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New

root_layout: {PentoWeb.LayoutView, :root},
This results in the following following error:
no “root” html template defined for PentoWeb...
New
Other popular topics

Which, if any, games do you play? On what platform?
I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New

My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New

I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New

The V Programming Language
Simple language for building maintainable programs
V is already mentioned couple of times in the forum, but I...
New

Seems like a lot of people caught it - just wondered whether any of you did?
As far as I know I didn’t, but it wouldn’t surprise me if I...
New

Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New

I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New

There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
New

Will Swifties’ war on AI fakes spark a deepfake porn reckoning?
New

This is cool!
DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON
We just witnessed something incredible: the largest open-s...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /onivim
- /svelte
- /typescript
- /crystal
- /kotlin
- /c-plus-plus
- /tailwind
- /gleam
- /ocaml
- /react
- /flutter
- /elm
- /vscode
- /ash
- /opensuse
- /centos
- /html
- /php
- /deepseek
- /zig
- /scala
- /sublime-text
- /textmate
- /lisp
- /nixos
- /debian
- /react-native
- /agda
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /django
- /spring
- /manjaro
- /nodejs
- /diversity
- /lua
- /julia
- /slackware
- /c
- /markdown