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
Read the answers on this topic from earlier today:
1
Popular in Questions
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
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
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 record...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
I have a list say
x = ["23gh", "56kh", "97mh"]
I would like to pass each element to Val in each iteration.
Say, in iteration 1 -------...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217
Let’s say I have a map with required and optional k...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Other popular topics
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
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
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New







