dogweather
Elixir for rules - as an alternative to Prolog or CLIPS?
I’ve been scratching out an idea in Prolog. But I’m wondering how Elixir’s functional paradigm would handle this kind of knowledge base. Has anyone done similar work?
At first glance, these look like multi-headed functions:
/*
* Crimes within the jurisdiction of the International Criminal Court.
*
* https://world.public.law/rome_statute/article_5_crimes_within_the_jurisdiction_of_the_court
*/
crime(genocide).
crime(war_crime).
crime(crime_against_humanity).
crime(crime_of_aggression).
/*
* A first, simple attempt at Protected Persons under
* the Geneva Conventions of 1949.
*/
protected_by_geneva_convention(P) :- civilian(P).
protected_by_geneva_convention(P) :- prisoner_of_war(P).
protected_by_geneva_convention(P) :- medical_personnel(P).
protected_by_geneva_convention(P) :- religious_personnel(P).
/*
* D = Defendant
* V = Victim
*/
/*
* Genocide
* https://world.public.law/rome_statute/article_6_genocide
*/
criminal_liability(genocide, Statute, D, V) :-
elements(Statute, D, V).
/*
* War crimes
* https://world.public.law/rome_statute/article_8_war_crimes
*/
criminal_liability(war_crime, Statute, D, V) :-
protected_by_geneva_convention(V),
international_conflict(D, V),
elements(Statute, D, V).
elements(article_8_2_a_i, D, V) :-
act(D, killed, V).
elements(article_8_2_a_ii, D, V) :-
act(D, tortured, V).
Most Liked
al2o3cr
That similarity isn’t an accident:
- Elixir’s multi-headed functions with pattern-matching are a direct translation of the Erlang features
- Erlang specifically cites Prolog’s syntax as inspiration, though with imperative semantics
- Erlang’s earliest prehistory is as a Prolog program (way back in 1986) - see the history in the introduction to Joe Armstrong’s thesis
2
al2o3cr
Also check out this thread:
1
Popular in Questions
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir?
...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
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
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
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Other popular topics
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
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
Hi!
Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









