Skip to content

Commit ab57ca5

Browse files
committed
feat(dsl): add method to create struct and numeric constants
1 parent c52e43b commit ab57ca5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main/scala/io/github/kelvindev15/prolog/dsl/PrologDSL.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import io.github.kelvindev15.prolog.core.Constant.Atom
44
import io.github.kelvindev15.prolog.core.PrologList.{Cons, Nil}
55
import io.github.kelvindev15.prolog.core.Struct.{Clause, Directive, Fact, Rule}
66
import io.github.kelvindev15.prolog.core.theory.Theory
7-
import io.github.kelvindev15.prolog.core.{PrologList, Struct, Term, Variable}
7+
import io.github.kelvindev15.prolog.core.{Constant, PrologList, Struct, Term, Variable}
88

99
import scala.annotation.targetName
1010

@@ -21,6 +21,13 @@ trait PrologDSL
2121
*/
2222
def theory(clauses: Clause*): Theory = Theory(clauses*)
2323

24+
/** Returns a [[Struct]].
25+
*
26+
* @param functor the functor of the struct.
27+
* @param arguments the arguments of the struct.
28+
*/
29+
def structOf(functor: Atom, arguments: Term*): Struct = Struct(functor, arguments*)
30+
2431
/** Returns a [[Fact]].
2532
*
2633
* @param fact
@@ -54,6 +61,12 @@ trait PrologDSL
5461
*/
5562
def atomOf(value: String): Atom = Atom(value)
5663

64+
/** Returns a [[Constant.Numeric]].
65+
*
66+
* @param value the value of the numeric constant.
67+
*/
68+
def numOf(value: (Int | Double)): Constant.Numeric = Constant.Numeric(value)
69+
5770
/** Returns a [[Variable]].
5871
*
5972
* @param name

0 commit comments

Comments
 (0)