crashangelbr
No Populate Variable in Loop Each rumtine, Why?
Hello, I am learning elixir and I am not managing to populate my variables at runtime … inside a loop .. Why do the variables go blank again every time?
def teste do
t = String.split("sentence [sentence] <sem-s> N F S @NPHR §DENOM #3->0", " ", trim: true)
token = ""
lemma = ""
syntax = ""
role = ""
child = ""
root = ""
tags = []
attrs = []
t
|> Enum.with_index()
|> Enum.each(fn {e, i} ->
if i == 0 do
token = e
else
# Verb
if i == 1 do
lemma = e
else
# Syntax
if i == Enum.count(t) - 3 do
syntax = e
else
# Role
if i == Enum.count(t) - 2 do
role = e
else
# Dependency
if i == Enum.count(t) - 1 do
e = String.replace(e, "#", "")
e = String.replace(e, "-", "")
child = Text.mid(e, String.slice(e, 0..0), ">")
root = Text.mid(e, ">")
# ===================================================
#Last Index >> Get All Variables and Inser in Mnesia
# ===================================================
IO.puts ">> #{token} >> #{lemma} >> #{syntax} >> #{role}"
else
# Tags
if String.contains?(e, ["<", ">"]) == true do
[e | tags]
else
# Attributes
[e | attrs]
end
end
end
end
end
end
end)
end
Most Liked
LostKobrakai
Popular in Questions
Hello, how can I check the Phoenix version ?
Thanks !
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










