Git Product home page Git Product logo

elxlog's Introduction

Elxlog

Small pure Prolog intepreter/compiler in Elixir. Project is called Elxlog. Goal is fusion of Elixir and Prolog

install

make clone or down load zip file

invoke

mix elxlog

quit

halt().

caution

  • predicate with zero arity is written like this. e.g. halt() true() fail()

  • Returns false for non-existent predicates.

  • There is no op/3.

  • float number is same as ISO-Prolog e.g. 3.0e4

  • comma and period is delimiter. Not operator.

  • The comparison operation is the same as C and Elixir. e.g. < > >= <= == !=

  • Anonymous variables in the same clause are not distinguished.

  • Elixir code can be mixed in the file read by reconsult/1. The line after "!Elixir" is Elixir code. see test.pl

  • There is no higher-order predicate such as call/1 assert/1 once/1. Within first order predicate logic.

  • Predicates with the same predicate name but different Arity are not allowed.

builtin

  append/3
  arg/3
  atom/1
  atomic/1
  between/3
  elixir/1  Run the Elixir code. See test.pl (e.g. elixir(elx_in_the_park()) )
  float/1
  fail/0
  functor/3
  halt/0
  integer/1
  is/2
  length/2
  listing/1
  member/2
  name/2
  nl/0
  nonvar/1
  not/1
  number/1
  read/1
  reconsult/1  (or ['filename.pl'])
  time/1
  true/0
  var/1
  write/1
  =/2
  </2
  >/2
  >=/2
  <=/2
  !=/2
  ==/2
  =../2

formula:
  +,^,*,/,^
  prefix "elx_" means Elixir function. See test.pl

Example

mix elxlog
Compiling 1 file (.ex)
Elxlog ver0.XX
?- ['test.pl'].
true
?- listing().
fact(0,1)
fact(N,A) :- is(N1,N-1),fact(N1,A1),is(A,N*A1).
likes(kim,robin)
likes(sandy,lee)
likes(sandy,kim)
likes(robin,cats)
likes(sandy,X) :- likes(X,cats).
likes(kim,X) :- likes(X,lee),likes(X,kim).
likes(X,X)
true
?- X is elx_ack(3,11).
X = 16381
true
?- fact(10,X).
X = 3628800
true
?- likes(sandy,Who).
Who = lee;
Who = kim;
Who = robin;
Who = sandy;
Who = cats;
Who = sandy;
false
?- append(X,Y,[1,2,3]).
X = []
Y = [1,2,3];
X = [1]
Y = [2,3];
X = [1,2]
Y = [3];
X = [1,2,3]
Y = [];
false
?- halt().
goodbye

compiler

Elxlog ver0.12
?- compile('test.pl').
true
?- ['test.o'].
true
?- my_member(2,[1,2,3]).
true
?- fact(10,X).
X = 3628800.
true
?-

parallel

builtin parallel/n

see test.pl pqsort/2 and pfib/2

Elxlog ver0.14
?- ['test.pl'].
true
?- time(fib(15,X)).
"time: 2790153 micro second"
X = 610
true
?- time(pfib(15,X)).
"time: 1082117 micro second"
X = 610
true
?-

elxlog's People

Contributors

sasagawa888 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.