
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

Whilst the author has been careful to provide exact results for the tests elsewhere in the book (such as surds with the transformation te...
New

Title: Web Development with Clojure, Third Edition, pg 116
Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New

When I try the command to create a pair of migration files I get an error.
user=> (create-migration "guestbook")
Execution error (Ill...
New

Running mix deps.get in the sensor_hub directory fails with the following error:
** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New

I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New

I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint.
As entered, the SwitchCompat changes color to hol...
New

Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
New

Hey there,
I’m enjoying this book and have learned a few things alredayd. However, in Chapter 4 I believe we are meant to see the “>...
New

It seems the second code snippet is missing the code to set the current_user:
current_user: Accounts.get_user_by_session_token(session["...
New

Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New
Other popular topics

@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness.
https://f...
New

You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New

Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
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

Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New

Hi folks,
I don’t know if I saw this here but, here’s a new programming language, called Roc
Reminds me a bit of Elm and thus Haskell. ...
New

Author Spotlight
James Stanier
@jstanier
James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New

Author Spotlight:
VM Brasseur
@vmbrasseur
We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New

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

A Brief Review of the Minisforum V3 AMD Tablet.
Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /ash
- /vscode
- /opensuse
- /centos
- /php
- /deepseek
- /scala
- /html
- /zig
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /django
- /spring
- /diversity
- /lua
- /nodejs
- /julia
- /slackware
- /c
- /neovim