predicates

package module
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2022 License: BSD-2-Clause, MIT Imports: 7 Imported by: 0

README

predicates GoDoc

import "github.com/guregu/predicates"

Native predicates for ichiban/prolog.

Prolog

Filesystem predicates use io/fs.FS.

Built-in replacements
  • consult/1
library(files)

These predicates are intended to be compatible with Scryer Prolog's library(files). These use strings (lists of characters) for filenames.

  • directory_files/2
  • directory_exists/1
  • file_exists/1
Lists
  • is_list/1
  • atomic_list_concat/3
Atoms
  • downcase_atom/2
  • upcase_atom/2
Package taujson

These predicates are intended to be compatible with Tau Prolog's library(js). They are peculiar predicates that use opaque native objects for JSON conversion.

  • json_atom/2
  • json_prolog/2
Graduated
  • between/3 made it into ichiban/prolog in v0.9.0!

Go

Package chars provides some convenience functions for working with Prolog strings.

License

BSD 2-clause. Includes code from ichiban/prolog (MIT license). See LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicListConcat added in v0.0.8

func AtomicListConcat(list, seperator, atom engine.Term, k func(*engine.Env) *engine.Promise, env *engine.Env) *engine.Promise

AtomicListConcat (atomic_list_concat/3) succeeds if atom represents the members of list joined by seperator. This can be used to join strings by passing a ground list, or used to split strings by passing a ground atom.

atomic_list_concat(+List, +Seperator, -Atom).
atomic_list_concat(-List, +Seperator, +Atom).

func DowncaseAtom added in v0.0.9

func DowncaseAtom(atom, lowercase engine.Term, k func(*engine.Env) *engine.Promise, env *engine.Env) *engine.Promise

DowncaseAtom (downcase_atom/2) converts atom into its lowercase equivalent.

downcase_atom(+Atom, -LowerCase).

func IsList added in v0.0.7

func IsList(t engine.Term, k func(*engine.Env) *engine.Promise, env *engine.Env) *engine.Promise

IsList (is_list/1) succeeds if the given term is a list.

is_list(@Term).

func UpcaseAtom added in v0.0.9

func UpcaseAtom(atom, uppercase engine.Term, k func(*engine.Env) *engine.Promise, env *engine.Env) *engine.Promise

UpcaseAtom (upcase_atom/2) converts atom into its uppercase equivalent.

upcase_atom(+Atom, -UpperCase).

Types

type FS

type FS struct {
	// contains filtered or unexported fields
}

FS provides native file system predicates. Non-ISO predicates are intended to maintain compatibility with Scryer Prolog's library(files). See: https://github.com/mthom/scryer-prolog/blob/master/src/lib/files.pl

func NewFS

func NewFS(fsys fs.FS, i *prolog.Interpreter) FS

NewFS returns a collection of filesystem predicates tied to fsys and i.

func (FS) Consult

func (ff FS) Consult(files engine.Term, k func(*engine.Env) *engine.Promise, env *engine.Env) *engine.Promise

Consult (consult/1) reads and executes the given file (if given an atom) or files (if given a list of atoms). ".pl" will be automatically appended to the file names when needed. Throws an error if files is not an atom or list of atoms.

consult(+FileOrList).

func (FS) DirectoryExists added in v0.0.4

func (ff FS) DirectoryExists(directory engine.Term, k func(*engine.Env) *engine.Promise, env *engine.Env) *engine.Promise

DirectoryExists (directory_exists/1) succeeds if a directory exists at the path given by the string directory. Throws an error if directory is not a string.

directory_exists(+Directory).

func (FS) DirectoryFiles added in v0.0.4

func (ff FS) DirectoryFiles(directory, files engine.Term, k func(*engine.Env) *engine.Promise, env *engine.Env) *engine.Promise

DirectoryFiles (directory_files/2) succeeds if files is a list of strings that contains all entries (including directories) of directory, which must be a string. This is useful for obtaining a list of files and directories. Throws an error if directory is not a string.

directory_files(+Directory, -Files).

func (FS) FileExists added in v0.0.4

func (ff FS) FileExists(file engine.Term, k func(*engine.Env) *engine.Promise, env *engine.Env) *engine.Promise

FileExists (file_exists/1) succeeds if a file exists at the path given by the string file. Throws an error if file is not a string.

file_exists(+File).

func (FS) Register

func (ff FS) Register()

Register is a convenience method that registers all FS predicates with their default names. This will replace the default consult/1. To register these with custom names, use the interpreter's Register functions and pass a method reference instead.

Directories

Path Synopsis
Package chars contains convenience functions for working with Prolog strings (list of characters).
Package chars contains convenience functions for working with Prolog strings (list of characters).
Package taujson provides JSON-related Prolog predicates compatible with Tau Prolog's library(js).
Package taujson provides JSON-related Prolog predicates compatible with Tau Prolog's library(js).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL