stop using submodule

This commit is contained in:
Vítor Santos Costa 2015-10-13 08:25:49 +01:00
parent 25c3010de6
commit 1a5ba98950
20 changed files with 5206 additions and 0 deletions

View File

@ -0,0 +1,58 @@
PROJECT ( YAP_REAL C )
macro_optional_find_package (R ON)
macro_log_feature (R_HOME "R"
"Use R Environment"
"http://www.r.org" FALSE)
if (R_HOME)
set (REAL_SOURCES
real.c
real.pl
)
include_directories (
${R_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
set (CMAKE_REQUIRED_INCLUDES
${R_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
#R_COMMAND - Path to R command
# R_HOME - Path to 'R home', as reported by R
# R_INCLUDE_DIR - Path to R include directory
# R_LIBRARY_BASE - Path to R library
# R_LIBRARY_BLAS - Path to Rblas / blas library
# R_LIBRARY_LAPACK - Path to Rlapack / lapack library
# R_LIBRARY_READLINE - Path to readline library
# R_LIBRARIES - Array of: R_LIBRARY_BASE, R_LIBRARY_BLAS, R_LIBRARY_LAPACK, R_LIBRARY_BASE [, R_LIBRARY_READLINE]
add_library (real SHARED ${REAL_SOURCES})
target_link_libraries (real ${R_LIBRARIES} libYap )
set_target_properties (real PROPERTIES PREFIX "")
check_include_files( R.h HAVE_R_H )
check_include_files ( "R.h;Rembedded.h" HAVE_R_EMBEDDED_H )
check_include_files( "Rembedded.h;Rinterface.h" HAVE_R_INTERFACE_H )
configure_file ("rconfig.h.cmake" "rconfig.h" )
install(TARGETS real
LIBRARY DESTINATION ${dlls}
)
install(FILES real.pl
DESTINATION ${libpl}
)
endif (R_HOME)

182
packages/real/LICENSE Normal file
View File

@ -0,0 +1,182 @@
Artistic License 2.0
Copyright (c) 2000-2006, The Perl Foundation.
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed. Preamble
This license establishes the terms under which a given free software
Package may be copied, modified, distributed, and/or
redistributed. The intent is that the Copyright Holder maintains some
artistic control over the development of that Package while still
keeping the Package available as open source and free software.
You are always permitted to make arrangements wholly outside of this
license directly with the Copyright Holder of a given Package. If the
terms of this license do not permit the full use that you propose to
make of the Package, you should contact the Copyright Holder and seek
a different licensing arrangement. Definitions
"Copyright Holder" means the individual(s) or organization(s) named in
the copyright notice for the entire Package.
"Contributor" means any party that has contributed code or other
material to the Package, in accordance with the Copyright Holder's
procedures.
"You" and "your" means any person who would like to copy, distribute,
or modify the Package.
"Package" means the collection of files distributed by the Copyright
Holder, and derivatives of that collection and/or of those files. A
given Package may consist of either the Standard Version, or a
Modified Version.
"Distribute" means providing a copy of the Package or making it
accessible to anyone else, or in the case of a company or
organization, to others outside of your company or organization.
"Distributor Fee" means any fee that you charge for Distributing this
Package or providing support for this Package to another party. It
does not mean licensing fees.
"Standard Version" refers to the Package if it has not been modified,
or has been modified only in ways explicitly requested by the
Copyright Holder.
"Modified Version" means the Package, if it has been changed, and such
changes were not explicitly requested by the Copyright Holder.
"Original License" means this Artistic License as Distributed with the
Standard Version of the Package, in its current version or as it may
be modified by The Perl Foundation in the future.
"Source" form means the source code, documentation source, and
configuration files for the Package.
"Compiled" form means the compiled bytecode, object code, binary, or
any other form resulting from mechanical transformation or translation
of the Source form.
Permission for Use and Modification Without Distribution
(1) You are permitted to use the Standard Version and create and use
Modified Versions for any purpose without restriction, provided that
you do not Distribute the Modified Version.
Permissions for Redistribution of the Standard Version
(2) You may Distribute verbatim copies of the Source form of the
Standard Version of this Package in any medium without restriction,
either gratis or for a Distributor Fee, provided that you duplicate
all of the original copyright notices and associated disclaimers. At
your discretion, such verbatim copies may or may not include a
Compiled form of the Package.
(3) You may apply any bug fixes, portability changes, and other
modifications made available from the Copyright Holder. The resulting
Package will still be considered the Standard Version, and as such
will be subject to the Original License.
Distribution of Modified Versions of the Package as Source
(4) You may Distribute your Modified Version as Source (either gratis
or for a Distributor Fee, and with or without a Compiled form of the
Modified Version) provided that you clearly document how it differs
from the Standard Version, including, but not limited to, documenting
any non-standard features, executables, or modules, and provided that
you do at least ONE of the following:
(a) make the Modified Version available to the Copyright Holder of the
Standard Version, under the Original License, so that the Copyright
Holder may include your modifications in the Standard Version. (b)
ensure that installation of your Modified Version does not prevent the
user installing or running the Standard Version. In addition, the
modified Version must bear a name that is different from the name of
the Standard Version. (c) allow anyone who receives a copy of the
Modified Version to make the Source form of the Modified Version
available to others under (i) the Original License or (ii) a license
that permits the licensee to freely copy, modify and redistribute the
Modified Version using the same licensing terms that apply to the copy
that the licensee received, and requires that the Source form of the
Modified Version, and of any works derived from it, be made freely
available in that license fees are prohibited but Distributor Fees are
allowed.
Distribution of Compiled Forms of the Standard Version or Modified Versions
without the Source
(5) You may Distribute Compiled forms of the Standard Version without
the Source, provided that you include complete instructions on how to
get the Source of the Standard Version. Such instructions must be
valid at the time of your distribution. If these instructions, at any
time while you are carrying out such distribution, become invalid, you
must provide new instructions on demand or cease further
distribution. If you provide valid instructions or cease distribution
within thirty days after you become aware that the instructions are
invalid, then you do not forfeit any of your rights under this
license.
(6) You may Distribute a Modified Version in Compiled form without the
Source, provided that you comply with Section 4 with respect to the
Source of the Modified Version.
Aggregating or Linking the Package
(7) You may aggregate the Package (either the Standard Version or
Modified Version) with other packages and Distribute the resulting
aggregation provided that you do not charge a licensing fee for the
Package. Distributor Fees are permitted, and licensing fees for other
components in the aggregation are permitted. The terms of this license
apply to the use and Distribution of the Standard or Modified Versions
as included in the aggregation.
(8) You are permitted to link Modified and Standard Versions with
other works, to embed the Package in a larger work of your own, or to
build stand-alone binary or bytecode versions of applications that
include the Package, and Distribute the result without restriction,
provided the result does not expose a direct interface to the Package.
Items That are Not Considered Part of a Modified Version
(9) Works (including, but not limited to, modules and scripts) that
merely extend or make use of the Package, do not, by themselves, cause
the Package to be a Modified Version. In addition, such works are not
considered parts of the Package itself, and are not subject to the
terms of this license.
General Provisions
(10) Any use, modification, and distribution of the Standard or
Modified Versions is governed by this Artistic License. By using,
modifying or distributing the Package, you accept this license. Do not
use, modify, or distribute the Package, if you do not accept this
license.
(11) If your Modified Version has been derived from a Modified Version
made by someone other than you, you are nevertheless required to
ensure that your Modified Version complies with the requirements of
this license.
(12) This license does not grant you the right to use any trademark,
service mark, tradename, or logo of the Copyright Holder.
(13) This license includes the non-exclusive, worldwide,
free-of-charge patent license to make, have made, use, offer to sell,
sell, import and otherwise transfer the Package with respect to any
patent claims licensable by the Copyright Holder that are necessarily
infringed by the Package. If you institute patent litigation
(including a cross-claim or counterclaim) against any party alleging
that the Package constitutes direct or contributory patent
infringement, then this Artistic License to you shall terminate on the
date that such litigation is filed.
(14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT
HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT
PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT
HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

90
packages/real/Makefile.in Executable file
View File

@ -0,0 +1,90 @@
################################################################
# YAP/SWI-Prolog R interface package
# Author: Nicos Angelopoulos
# Copyright: Perl License
################################################################
PACKAGE=real
DOC=real
PKGCFLAGS=@REAL_INCLUDES@
REAL_LIBS=@REAL_LIBS@
include ../Makefile.defs
OBJS= real.o
SOLIBS= real.@SO@
LIBPL= real.pl
all: @REAL_TARGET@
ritf: $(SOLIBS)
dummy::
# this has be compatible with a name from expansion of --with-R=Dir or
# with a set of quoted names from REXEC CMD
real.o: $(srcdir)/real.c
$(CC) -c $(CFLAGS) -I. $< -o $@
real.@SO@: $(OBJS)
$(LD) $(LDSOFLAGS) -o $@ $(OBJS) $(LIBS) $(REAL_LIBS) $(LIBPLSO)
install: install-@REAL_TARGET@
install-dummy::
install-ritf: $(SOLIBS) $(addprefix $(srcdir)/, $(LIBPL))
mkdir -p $(DESTDIR)$(SOLIBDIR)
rm -f $(DESTDIR)$(SOLIBDIR)/real.@SO@
$(INSTALL_PROGRAM) $(SOLIBS) $(DESTDIR)$(SOLIBDIR)
mkdir -p $(DESTDIR)$(PLLIBDIR)
for f in $(LIBPL); do \
$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(PLLIBDIR); \
done
$(MKINDEX)
ln-install::
$(MAKE) INSTALL_DATA="../ln-install" INSTALL_PROGRAM="../ln-install" install
rpm-install: install
html-install::
mkdir -p $(DESTDIR)$(PKGDOC)
$(INSTALL) -m 644 $(DOC).html $(DESTDIR)$(PKGDOC)
pdf-install::
mkdir -p $(DESTDIR)$(PKGDOC)
$(INSTALL) -m 644 $(DOC).pdf $(DESTDIR)$(PKGDOC)
uninstall::
(cd $(SOLIBDIR) && rm -f $(TARGETS))
(cd $(PLBASE)/library && rm -f $(LIBPL))
$(MKINDEX)
################################################################
# Documentation
################################################################
TEXEXTRA= libreal.tex
$(TEX): $(TEXEXTRA)
libreal.tex: $(srcdir)/real.pl
$(PLTOTEX) --section 'library(real)' --out=$@
################################################################
# Testing
################################################################
check::
$(PL) -q -f examples/test_real.pl -g test_real,halt -t 'halt(1)'
################################################################
# Clean
################################################################
clean:
rm -f $(SOLIBS) *~ *.o *% a.out core config.log
distclean: clean
rm -f $(TARGETS) config.cache config.h config.status Makefile
rm -f $(DOC).aux $(DOC).log $(DOC).out $(DOC).toc
rm -rf html
rm -rf autom4te.cache

24
packages/real/Makefile_so Normal file
View File

@ -0,0 +1,24 @@
# skeleton Makefile for cross compiling windows for SWI
# alot of the work is done by a prolog script that
# uses includes and R dlls in my disk space and includes those ala
# buildenv.sh (on the fly)
#
SOBJ= $(PACKSODIR)/real.$(SOEXT)
CFLAGS+=-std=c99
LIBS= -lR
all: $(SOBJ)
$(SOBJ): real.o
mkdir -p $(PACKSODIR)
$(LD) $(ARCH) $(LDSOFLAGS) -o $@ $< $(LIBS) $(SWISOLIB)
real.o:
$(CC) $(ARCH) $(CFLAGS) -c -o real.o real.c
check::
install::
clean:
rm -f real.o
distclean: clean
rm -f $(SOBJ)

59
packages/real/README.md Normal file
View File

@ -0,0 +1,59 @@
Real
---
Real is a c-based interface for connecting R to Prolog.
YAP introduces a development version of real, developed to experiment
with the internals of the implementation of R. It includes major
changes and is likely to be much less stable than the version
maintained by Nicos ANgelopoulos. We refer to the version herein as
'realC' and describe the main novelties vs the version described
in~\cite{}. Their major differences:
- Most of realC is written in `C`, instead of aa a Prolog string
generator. The `C` code respects the SWI-Prolog fli interface and
should work both in YAP and in SWI-Prolog.
- realC uses Prolog atoms to represent real variables. R sequences
of characters are represented as Prolog strings (not as lists of
character codes). The atoms `true` and `false` indicate boolean
constants.
By default, YAP represents sequences of codes using double
quotes, and strings by back quotes. Please consult the
documentation o the ISO-Prolog flag `double_quotes` if you using
prefer reading double-quote strings as Prolog string.
- Free variables can be used to represent missing
arguments,ie. `a[_,"G23"] would represent the column "G23".
- All recent versions of real support the common syntax extensions
for [], (), thus realC allows writing `a[[2]] <- f().
- YAP allows A.B to be interpreted as [A|B]. This version takes
advantage of this implementation quirk, and allows one to write
expressions such as `a.b[2] <- f.g()`.
- The left-hand side msy be:
+ a ground unary term, assumed to be an attribute
+ an index
+ an R variable
+ a logic variable, or other Prolog term: in this case it will be
unified with the result of evaluating the right-hamd side.
Yap
?- [examples/for_real].
?- for_real.
---
Nicos Angelopoulos and Vitor Santos Costa
December, 2012.
Updates: Nicos Angelopoulos
Dec. 2013,
March, 2014
Updates: Vitor Santos Costa
Dec. 2015

103
packages/real/configure.in Executable file
View File

@ -0,0 +1,103 @@
dnl Process this file with autoconf to produce a configure script.
m4_ifdef([HAS_TOP],[m4_ignore],[
AC_INIT(install-sh)
AC_PREREQ([2.50])
AC_CONFIG_HEADER(config.h)
])
AC_SUBST(REAL_INCLUDES)
AC_SUBST(REAL_LIBS)
AC_SUBST(REAL_TARGET)
AC_ARG_WITH(R,
[ --with-R[=DIR] interface to the R language],
if test "$withval" = yes; then
yap_cv_R=yes
elif test "$withval" = no; then
yap_cv_R=no
else
yap_cv_R=$withval
fi,
[yap_cv_R=no])
m4_ifdef([HAS_TOP],[m4_ignore],[ m4_include([../ac_swi_c.m4]) ])
if test "$host" != "$build" -a "$yap_cv_R" != "yes"
then
# cross-compiler
REAL_TARGET="ritf"
REAL_INCLUDES=-I"'""$yap_cv_R""'"/include
case "$target_cpu" in
i*86*)
REAL_LIBS="-L"'""$yap_cv_R""'"/bin/i386 -lR"
;;
x86*)
REAL_LIBS="-L"'""$yap_cv_R""'"/bin/x64 -lR"
;;
**)
REAL_TARGET="dummy"
;;
esac
else
# default instalation
if test "$yap_cv_R" = "yes"
then
#assumes we have r on path
AC_CHECK_PROGS(REXE, [R.exe R r], "none", [ $PATH ] )
else
AC_CHECK_PROGS(REXE, [R.exe R r], "none", [ "$yap_cv_R"/bin:$PATH ] )
fi
#it worked?
if test "$REXE" = none -o x"$REXE" = "x"; then
REAL_TARGET="dummy"
#give up on installing R, we couldn't find it.
else
REAL_TARGET="ritf"
REAL_INCLUDES="$( $REXE CMD config --cppflags | grep -v ^WARNING)"
REAL_LIBS="$($REXE CMD config --ldflags | grep -v ^WARNING)"
# if non-nil we're done
if test x"$REAL_INCLUDES" = x; then
REAL_INCLUDES=-I\"$yap_cv_R\"/include
case "$target_cpu" in
i*86*)
REAL_LIBS="-L\"$yap_cv_R/bin/i386\" -lR"
;;
x86*)
REAL_LIBS="-L\"$yap_cv_R/bin/x64\" -lR"
;;
**)
REAL_TARGET="dummy"
;;
esac
fi
fi
fi
if test $REAL_TARGET = "ritf"
then
ocppflags="$CPPFLAGS"
ocflags="$CFLAGS"
CPPFLAGS+=" $REAL_INCLUDES"
CFLAGS+=" $REAL_INCLUDES"
AC_CHECK_HEADERS(R.h)
AC_CHECK_HEADERS(Rembedded.h)
AC_CHECK_HEADERS(Rinterface.h)
CFLAGS="$ocflags"
CPPFLAGS="$ocppflags"
fi
m4_ifdef([HAS_TOP],[m4_ignore], [AC_OUTPUT(Makefile)
AC_OUTPUT(rconfig.h)])

View File

@ -0,0 +1,50 @@
1:1:2 ?
Fixed x <- list(). on Swi 7.
Cushioned Yap use by wrapping thread_self/1 to real_thread_self/1.
1:1:0 2014/02/15 (thankless_task)
Added support for threaded execution.
We need to look into environments to make deployment easier.
1:0:4 2014/12/25
Fixed passing unamed R lists to Prolog pairs. Missing name is the number
position. Added example for that.
0:1:2 2013 November 3 (the_stoic)
Added support for a[x,y] and a().
Corrected some branch variables, thanks to new Swi warnings.
Jan, added some stuff on strings support.
0:1:1 2013 January 17 (cross_compiled)
swipl-win.exe doesnot use the std I/O streams. So <-print/1 doesnot display
on console. Added message that only displays when Prolog was started with
swipl-win.exe and only once. The windows dlls are now cross compiled.
There are now also shared (.so) libs for linux i386 and x86_64.
Added Makefile.swi to the sources.
0:1:0 2012 December 26 [oliebollen]
First release with updated syntax, documentation and Windows binaries.
Reflects state of affairs for the PADL 2013 related publication.
Great work by Vitor on passing c() via C and on utf support.
0:0:5 2012 September 12
?fixed? * in array indicators (tut5) broken (why ?).
Moved real_ex.pl to examples/for_real.pl
Fixed ' x <- list(.), x$a <- 3. '. Added to examples (composite_list).
In readme.txt autoconfig -> autoconf.
Support $ as term.
Expand the cases understood as printable to include ^ and $.
Added r_wait/0.
0:0:4 2012 May 24
Fixed translation of P <- (v1-v2)^2, (report: Michiel Hildebrand)
Added a (v1-v2)^2 example to real_ex.pl .
0:0:3 2012 Feb ??
Complete re-writing of the C-code for SWI interface. (80% done by Jan Wielimeker.)
Added examples/pagerank.pl (Vitor Santos Costa).
0:0:2 2011 Dec ??
0:0:1 2011 Dec ??
First two releases only shown to Vitor and Jan.

View File

@ -0,0 +1,7 @@
On MacOs the macports binary seems not to be working properly (eg median()). (Michiel Hildebrand, May 2012). The issue does not persist for MacOS binaries (i assume) from R.
On windows XP the setting of PATH does not seem to be work from within Prolog.
User needs to set the PATH to include the R.dll directory (and possibly R_HOME/modules/<exec-arch>/)
through the graphical interface ( right-click on computer and then add to the User or System
environment variable PATH).

View File

@ -0,0 +1,34 @@
Close connection at halt (any change of at_halt/1 Vitor ?!!).
Investigate why plot_cpu/1 needs so much stack. (does it stilL ?)
Investigate the x.y notation and see if SWI can cope with it.
Calling functions natively ?
We could drop the <- operator even, just hook an exception
handler for predicates that are not there !!!
--- threads (SWI, specific ?)
The R OS lib is thread-unsafe, add a Prolog layer to cope with this ?
Jan on Mailing list : 2013/1/10,
worker thread. Just create a thread named 'R' and initialize R.
If you want to do something with R, use
thread_self(Me),
thread_send_message('R', process(Me, <data>)),
thread_get_message(r_reply(Result))
and in the R thread, in a loop:
thread_get_message(process(Sender, Data)),
r_compute(Data, Result),
thread_send_message(Sender, r_reply(Result)).
Of course, you need to make all this a bit cleaner and handle errors,
etc, but this is the basic idea.
--- r_session compatibility add-on ?
one that would also solve the threading issue ?

View File

@ -0,0 +1,690 @@
:- ensure_loaded( library(real) ).
:- ensure_loaded( library(lists) ).
:- use_module( library(apply_macros) ).
:- use_module( library(readutil) ).
:- set_prolog_flag(double_quotes, string).
% for_real.
%
% Some examples illustrating usage of the r..eal library.
for_real :-
( Head = ex(_Ex); Head = tut(_Tut) ),
clause( Head, Body ),
write(running:Head), nl, nl,
portray_clause( (Head:-Body) ), nl, nl,
write( 'Output: ' ), nl,
( catch(Head,Exc,Fex=true) ->
( Fex==true->
write( '! ' ), write( caught(Exc) ), nl, abort
;
write(status:true)
)
;
write( '! ' ), write( failure ), nl, abort
),
nl, nl, write('-----'), nl, nl,
fail.
for_real :-
write( 'All done.' ), nl.
% ex(int).
%
% Pass the salt please.
% The most basic example: pass a Prolog list of integers to an R variable
% and then back again to a Prolog variable.
%
ex(int) :-
i <- [1,2,3,4],
<- i,
I <- i,
write( i(I) ), nl.
% float.
%
% Pass a Prolog list of floats to an R variable and then back again to a Prolog variable.
%
ex(float) :-
f <- [1.0,2,3,4],
<- f,
F <- f,
write( f(F) ), nl.
% ex( float ).
%
% Pass a mixed Prolog list of integers and floats to an R variable and
% then back again to a Prolog variable.
% The returning list is occupied by floats as is the R variable.
%
ex(to_float) :-
m <- [1,2,3,4.0],
<- m,
M1 <- m,
write( m(M1) ), nl,
m <- [1,2,3,4.1],
<- m,
M2 <- m,
write( m(M2) ), nl.
% ex(bool).
%
%
ex(bool) :-
b <- [true,false,true,true],
<- print( b ),
B <- b,
write( b(B) ), nl.
% at_bool.
%
% In cases where disambiguation is needed, boolean values can be represented by @Val terms.
%
ex(at_bool) :-
b <- [@true,@false,@true,@true],
<- print( b ),
B <- b,
write( at_b(B) ), nl.
% ex(bool_f).
%
% This fails since there is a non boolean value in a list.
%
% On SWI this fails...
% On YAP this throuws exception....
%
ex(bool_f) :-
( catch(b <- [true,false,true,true,other],_,fail) ->
fail
;
true
).
% ex(bool_back).
%
% Get some boolean values back from applying a vector element equality to an integer
% vector we just passed to R. Prints the R bools first for comparison.
%
ex(bool_back) :-
t <- [1,2,3,4,5,1],
<- print(t),
s <- t==1,
<- print(s),
S <- s,
write( s(S) ), nl.
% ex(atom_char).
%
% Pass some atoms to an R vector of characters.
%
ex(atom_char) :-
f <- [a,b,c],
<- f,
F <- f,
write( f(F) ), nl.
% ex(matrix_int).
%
% Pass a 2-level list of lists of integers to an R matrix (and back again).
%
ex(matrix_int) :-
a <- [[1,2,3],[4,5,6]],
<- print(a),
A <- a,
nl, write( a(A) ), nl.
% ex(matrix_char).
%
% Pass a 2-level list of lists of characters to an R matrix (and back again).
%
ex(matrix_char) :-
a <- [[a,b,c],[d,e,f]],
<- print(a),
A <- a,
write( a(A) ), nl.
% ex(matrix_idx).
%
ex(matrix_idx) :-
a <- [[1,2,3],[4,5,6]],
<- a,
J <- a[1,_],
write( j(J) ), nl.
% ex(list).
%
% A Prolog = pairlist to an R list. Shows 2 alternative ways to access the list items.
%
ex(list) :-
a <- [x=1,y=0,z=3],
A <- a,
X0 <- a[1],
format( 'First pair of list: ~w~n', [X0] ),
X <- a[[1]],
format( 'First element of list: ~w~n', [X] ),
Y <- a$y,
format( 'Second element of list: ~w~n', [Y] ),
write( a(A) ), nl.
% ex(list).
%
% R allows for unamed lists.
%
ex(unamed) :-
li <- list(),
li[[1]] <- c(1,2,3),
<- li,
L <- li,
write( l(L) ), nl.
% ex(list_ea).
%
% Produces error due to name of constructor: -.
%
ex(list_ea) :- % produces error
catch_controlled( a <- [x=1,y=0,z-3] ),
<- a,
A <- a,
write( a(A) ), nl.
% ex(list_eb).
%
% Produces an error due to mismatch of arity of =.
%
ex(list_eb) :-
catch_controlled( a <- [x=1,y=0,=(z,3,4)] ),
<- a,
A <- a,
write( a(A) ), nl.
% ex(char_list).
%
% Pass a list which has a char value.
%
ex(char_list) :-
a <- [x=1,y=0,z="three"],
<- print(a),
A <- a,
memberchk( Z="three", A ),
write( z(Z):a(A) ), nl.
% ex(mix_list).
%
% An R-list of mixed types.
%
ex(mix_list) :-
a <- [x=1,y=[1,2,3],z=[[a,b,c],[d,e,f]],w=[true,false]],
A <- a,
<- print(a),
write( a(A) ), nl.
% ex(list2).
%
% Illustrates ways of accessing list elements.
%
ex(list2) :-
l <- list(),
l[["what"]] <- c(1,2,3),
l$who <- c(4,5,6),
<- print(l),
L <- l,
write( l(L) ), nl.
% ex(slot).
%
% Creating formal objects and accessing their content.
%
ex(slot) :-
<- setClass("track", representation(x="numeric", y="numeric")),
myTrack <- new("track", x = -4:4, y = exp(-4:4)),
<- print( myTrack@x ),
% [1] -4 -3 -2 -1 0 1 2 3 4
Y <- myTrack@y,
write( y(Y) ), nl,
<- setClass("nest", representation(z="numeric", t="track")),
myNest <- new("nest", z=c(1,2,3) ),
myNest@t <- myTrack,
myNest@t@x <- Y+1, % good ex. for hidden vars.
<- print( myNest ),
% N <- myNest, % unsupported r-type
% X <- myNest@t@x,
<- print(myNest@t@x),
X <- myNest@t@x,
<- print( myNest@t@x ),
write( x(X) ), nl.
% myTrack@x <- c(1,2,3).
% ex(add_element).
%
% Adds a third element to a list after creation.
%
ex(add_element) :-
x <- [a=1,b=2],
x$c <- [3,4],
<- print( x ), % print = $a 3
X <- x,
write( x(X) ), nl. % X = [a=3.0].
% ex(singletons).
%
% Pass an integer and a singleton number list and get them back.
% Although in R both are passed as vectors of length on, when back in Prolog
% the singleton list constructors are stripped, returing a single integer value in both cases.
%
ex(singletons) :-
s <- 3,
<- print(s),
S <- s,
<- print( s ),
t <- [3],
<- print( t ),
T <- t,
write( s(S)-t(T) ), nl.
% ex(assign).
%
% Simple assignment of an R function (+) application on 2 R values originated in Prolog.
%
ex(assign) :-
a <- 3,
<- print( a ),
b <- [2],
<- print( b ),
C <- a + b,
write( c(C) ), nl.
% ex(assign_1).
%
% Assign the result of an R operation on matrix and value to a Prolog variable.
%
ex(assign_1) :-
a <- [[1,2,3],[4,5,6]],
<- a,
B <- a*3,
write( b(B) ), nl.
% ex(assign_2).
%
% Assign the result of an R operation on matrices to a Prolog variable.
%
ex(assign_2) :-
a <- [[1,2,3],[4,5,6]],
<- print( a ),
b <- 3,
<- print( b ),
C <- a*b,
write( c(C) ), nl.
% ex(assign_r).
%
% Assign values to R variables and operate on them.
% Using c as an R variable is also a good test, as we test against c(...).
%
ex(assign_r) :-
a <- [3],
<- print( a ),
b <- [2],
<- print( b ),
c <- a + b,
<- print( c ).
/* disable for now. once Yap supports . in atoms
re-establish this, but make sure you restor
relevant flag back to its original setting. */
% ex(dot_in_function_names).
%
% Test dots in functions names via the .. mechanism.
%
ex(dot_in_function_names) :-
a <- [1.1,2,3],
<- print(a),
x <- as.integer(a),
<- print(x).
/* as above */
% ex(dot_in_rvars).
%
% Test dots in R variable names via the .. mechanism. Generates an error on the last goal.
%
ex(dot_in_rvar) :-
a.b <- [1,2,3],
<- print( a.b ),
<- print( 'a.b' ),
catch_controlled( <- print('a..b') ).
% ex(semi_column).
%
% A:B in R generates a vector of all integers from A to B.
%
ex(semi_column) :-
z <- 1:50,
<- print( z ),
Z <- z,
length( Z, Len ),
write( len(Len) ), nl.
% ex(c_vectors).
%
% r.eal also supports c() R function concatenation.
%
ex(c_vectors) :-
a <- c(1,2,3,5), % this goes via the fast route
<- print(a),
b <- c(1,1,2,2) + c(1:4),
<- print( b ),
C <- a+b,
write( 'C'(C) ), nl.
% ex(empty_args).
%
% Test calling R functions that take no arguments (via foo()).
%
ex(empty_args) :-
<- plot( 1:10, 1:10 ),
findall( I, (between(1,6,I),write('.'), flush_output, sleep(1)), _ ),
nl,
<- dev.off(). % fixme use dev.off() when Yap starts supporting it.
% ex(string).
%
% Test new (2013/11/22) string type in SWI Prolog v7.
%
ex(string) :-
( (current_predicate(string/1),string("abc")) ->
<- plot( 1:10, 1:10, main="native string type has arrived to Prolog" ),
findall( I, (between(1,6,I),write('.'), flush_output, sleep(1)), _ )
;
true
).
% ex(binary_op).
%
% Early versions of r..eal were not handling this example properly.
% Thanks to Michiel Hildebrand for spotting this.
% The correct answer is =|[0.0,4.0]|=. First subtract v1 from v2 and then take power 2.
%
ex(binary_op) :-
v1 <- c(1,1),
<- print( v1 ),
v2 <- c(1,-1),
<- print( v2 ),
P <- (v1-v2)^2,
write( P ), nl.
% not !!! : P = [0.0, 0.0].
% ex(utf).
%
% Plots 3 points with the x-axis label showing some Greek letters (alpha/Omega).
%
ex(utf) :-
<- plot( c(1,2,3), c(3,2,1), xlab= "αω" ),
findall( I, (between(1,4,I),write('.'), flush_output, sleep(1)), _ ),
nl,
<- dev.off().
% ex(utf_atom).
%
% Plots 3 points with the x-axis label showing some Greek letters (alpha/Omega) as atom preceded by +.
%
ex(utf_atom) :-
<- plot( c(1,2,3), c(3,2,1), xlab= "α/Ω" ),
findall( I, (between(1,4,I),write('.'), flush_output, sleep(1)), _ ),
nl,
<-dev.off().
% ex( utf_1 ).
%
% Thanks to Guillem R.
%
ex(utf_1) :-
s <- ['Pour ce garçon être sur une île, y avoir des histoires de cœur ambiguës et vider un fût de bière sur un canoë entouré par des caïmans, ne fut pas un mince affaire.'],
<- print( s ),
S <- s,
write( s(S) ), nl.
% ex( utf1 ).
%
% Mostly Vitor's then Sander and last one from Nicos.
%
ex(utf_2) :-
x <- [hello, 'olá', 'जैसा कहर बरपा तो बर्बाद हो जाएगी मुंबई','Beëindigen','άμπελος'],
<- x,
X <- x,
write( x(X) ), nl.
% ex(plot_cpu).
%
% Create a plot of 4 time points. Each having a push and a pull time component.
% These are the time it takes to push a list through to R and the time to Pull the same
% (very long) list back.
%
ex(plot_cpu) :-
plot_cpu( 1000 ).
ex(debug) :-
real_debug,
write( started_debugging ), nl,
x <- c(1,2,3), % c-vectors
y <- [1,2,3], % PL data lists
X <- x, % R var to PL var
x <- [a=[1,2,4],b=[4,5,6]],
A <- x,
B <- x$b, % R expression to PL var
Y <- x$b + x$a,
x$c <- [6,3,7],
real_nodebug,
write( x(X) ), nl,
write( a(A) ), nl,
write( b(B) ), nl,
write( y(Y) ), nl,
write( stopped_debugging ), nl.
% ex(rtest).
% Some tests from r_session,
%
ex(rtest) :-
<- set.seed(1), % fixme: dot
y <- rnorm(500),
<- print(y),
x <- rnorm(y),
<- print(x),
% <- x11(width=5,height=3.5),
<- plot(x,y),
r_wait,
<- dev.off(),
Y <- y,
write( y(Y) ), nl,
findall( Zx, between(1,9,Zx), Z ),
z <- Z,
<- print( z ),
cars <- [1, 3, 6, 4, 9],
% cars <- c(1, 3, 6, 4, 9),
<- print(cars),
<- pie(cars),
r_wait,
<- dev.off().
% list_times.
%
% Print some timing statistics for operations on a long list of integers.
%
list_times :-
findall( I, between(1,10000000,I), List ),
statistics( cputime, Cpu1 ), write( cpu_1(Cpu1) ), nl,
l <- List,
a <- median( l ),
statistics( cputime, Cpu2 ), write( cpu_2(Cpu2) ), nl,
b <- median( List ),
statistics( cputime, Cpu3 ), write( cpu_3(Cpu3) ), nl,
<- print(a),
<- print(b).
% adapted from YapR
% Intrinsic attributes: mode and length
tut(tut1) :-
z <- 0:9,
<- print(z),
digits <- as.character(z), % fixme: dot
<- print(digits),
d <- as.integer(digits), % fixme: dot
<- print(d).
% changing the length of an object
tut(tut2) :-
e <- numeric(),
(e[3]) <- 17,
<- print(e),
alpha <- 1:10,
alpha <- alpha[2 * 1:5],
<- alpha, % = 2, 4, 6, 8 10
length(alpha) <- 3,
<- print(alpha), % = 2, 4, 6
nl, write( ' on beta now ' ), nl, nl,
beta <- 1:10,
beta <- 2 * beta,
<- print(beta), % 2 4 6 8 10 12 14 16 18 2
length(beta) <- 3,
<- print(beta). % 2 4 6
% Getting and setting attributes
tut(tut3) :-
z <- 1:100,
attr(z, "dim") <- c(10,10),
<- print( z ).
% factors and tapply.
tut(tut4) :-
/* state <- c("tas", "sa", "qld", "nsw", "nsw", "nt", "wa", "wa",
"qld", "vic", "nsw", "vic", "qld", "qld", "sa", "tas",
"sa", "nt", "wa", "vic", "qld", "nsw", "nsw", "wa",
"sa", "act", "nsw", "vic", "vic", "act"), */
state <- [tas,sa,qld,nsw,nsw,nt,wa,wa,qld,vic,nsw,vic,qld,qld,sa,tas,sa,nt,wa,vic,qld,nsw,nsw,wa,sa,act,nsw,vic,vic,act],
<- print( state ),
% <- astate,
statef <- factor(state),
<- print( statef ),
<- levels(statef),
incomes <- c(60, 49, 40, 61, 64, 60, 59, 54, 62, 69, 70, 42, 56,
61, 61, 61, 58, 51, 48, 65, 49, 49, 41, 48, 52, 46,
59, 46, 58, 43),
incmeans <- tapply(incomes, statef, mean),
% notice the function definition.
stderr <- ( function(x) -> sqrt(var(x)/length(x)) ),
% <- print( stderr ),
X <- stderr( [1,2,3,4,5,6,7,8,9,10] ),
writeln(stderr=X),
incster <- tapply(incomes, statef, stderr),
<- print( incster ).
tut(tut5) :-
z <- 1:1500,
dim(z) <- c(3,5,100),
a <- 1:24,
dim(a) <- c(3,4,2),
<- print(a[2,_,_]),
<- print(dim(a)),
x <- array(1:20, dim=c(4,5)),
<- print( x ),
i <- array(c(1:3,3:1), dim=c(3,2)),
<- print( i ),
x[i] <- 0,
<- print( x ),
h <- 1:10,
z <- array(h, dim=c(3,4,2)),
<- print( z ),
a <- array(0, dim=c(3,4,2)),
<- print( a ),
% ab <- z '%o%' a,
ab <- z+a, % z @^@ a,
<- ab,
f <- ( function(xx, yy) -> cos(yy)/(1 + xx^2) ),
w <- outer(z, a, f),
<- w.
tut(tut6) :-
d <- outer(0:9, 0:9),
fr <- table(outer(d, d, "-")),
<- plot(as.numeric(names(fr)), fr, type="h", xlab="Determinant", ylab="Frequency"), % fixme: dot
format( '~n type :- "dev.off()." to close the plot display.~n', []).
tut(tut7) :-
m <- function(x) -> [ array(a), (a[x]<- x), while((x > 0), [x <-x-1, a[x] <- a[x+1]+x]), a[0] ],
m(100),
X <- a,
writeln(X).
% auxiliary,
cpu_points( [], [], [] ).
cpu_points( [H|T], [S|Ss], [L|Ls] ) :-
between_1_and(H,Long),
statistics( cputime, _) ,
length( Long, Lengtho ), write( leno(Lengtho) ), nl,
statistics( cputime, S0 ),
( number(S0) -> S0 = S ; S0 = [_,S] ),
% statistics( cputime, [_,S] ),
long <- Long,
Back <- long,
Back = [Hb|_],
Hb =:= 1,
statistics( cputime, L0 ),
( number(L0) -> L0 = L ; L0 = [_,L] ),
% statistics( cputime, [_,L] ),
length( Back, BackLen ),
write( back_len(BackLen) ), nl,
% L = 0,
cpu_points( T, Ss, Ls ) .
% auxiliaries,
catch_controlled( Expr ) :-
catch( Expr, Caught, true ),
( \+ var(Caught) -> write( caught_controlled(Caught) ), nl; fail ).
between_1_and(N,X) :-
( var(N) -> N is 100; true ),
IntN is integer(N),
findall( I, between(1,IntN,I), Is ),
i <- Is,
X <- i.
cpu( R ) :-
( var(R) -> R is 10000; true ),
findall( F, between_1_and(R,F), Fs ),
f <- Fs,
statistics( cputime, Cpu1 ),
write( cputime_to_push(Cpu1) ), nl,
X <- f, % when F <- f the predicate fails midway for large Len !!!
statistics( cputime, Cpu2 ),
write( cputime_to_pull(Cpu2) ), nl,
length( X, Len ),
write( len(Len) ), nl.
plot_cpu( Factor ) :-
nl,
( Factor > 10 ->
M='if your set-up fails on this test increase the size of stack.',
write( M ), nl, nl
;
true
),
points <- [10,100,500,1000],
points <- as.integer( points * Factor ), % fixme: dot
<- points,
Points <- points,
write( points(Points) ), nl,
cpu_points( Points, Push, Pull ),
push <- Push,
pull <- Pull,
write( plotting(Pull,Push) ), nl,
<- plot( points, pull, ylab = "pull & push (red) - in seconds" ),
<- points( points, push, col="red" ).

View File

@ -0,0 +1,82 @@
:- use_module(library(real)).
%:- r(install..packages("igraph")).
:- r(library("igraph") ).
aleph :-
pagerank('aleph.pl').
pagerank(F) :-
% g <- graph([0,0],n=1000),
parse(F,S),
g <- graph(S),
r <- page..rank(g),
Scores <- r$vector,
max_element(Scores, I, V),
found(N, A, I),
format('most linked predicate is ~a/~d, score ~2f.~n',[N,A,V]).
max_element(S, IF, VF) :-
S = [V|Els],
max_element(Els, V, 0, 0, IF, VF).
max_element([], VF, IM, _, IM, VF).
max_element([V|Els], VM, _IM, I0, IF, VF) :-
V > VM, !,
I is I0+1,
max_element(Els, V, I0, I, IF, VF).
max_element([_|Els], VM, IM, I0, IF, VF) :-
I is I0+1,
max_element(Els, VM, IM, I, IF, VF).
parse(File, L) :-
open(File, read, S),
findall(O, process(S, O),L),
close(S).
process(S, O) :-
repeat,
read(S, T),
% writeln(T),
(
T == end_of_file -> !, fail ;
do(T, O)
).
do((A :- B), O) :-
id(A, IDA),
process_body(B, IDA, O).
do((:- G),_) :- catch(call(G),_,fail), !, fail.
process_body(B, _IDA, _) :- var(B), !, fail.
process_body((B1,B2), IDA,O) :- !,
process_body(B1, IDA, O) ;
process_body(B2, IDA, O).
process_body((B1;B2), IDA, O) :- !,
process_body(B1, IDA, O) ;
process_body(B2, IDA, O).
process_body((B1->B2), IDA, O) :- !,
process_body(B1, IDA, O) ;
process_body(B2, IDA, O).
process_body(B, IDA, O) :-
id(B,IDB),
( O = IDB; O = IDA ).
% r(add..edges(g,c(IDA,IDB))).
:- dynamic ids/1, found/3, exists/2.
new(IDA,IDB) :-
\+ exists(IDA,IDB),
assert(exists(IDA,IDB)).
id(F, I) :-
functor(F,N,A),
(found(N,A,I) -> true ; new(N, A, I) ).
ids(0).
new(N, A, I) :-
retract(ids(I)),
I1 is I+1,
assert(found(N,A,I)),
assert(ids(I1)).

View File

@ -0,0 +1,28 @@
:- module(test_real,
[ test_real/1
]).
:- asserta(user:file_search_path(foreign, '.')).
:- asserta(user:file_search_path(library, '.')).
:- asserta(user:file_search_path(library, '../plunit')).
:- use_module( library(real) ).
:- use_module(library(plunit)).
test_real(_) :-
run_tests([ real
]).
:- begin_tests(real).
test(int_array) :-
x <- c(1,2,3),
X <- x,
X == [1,2,3].
test(mixed_array) :-
y <- c(1,2,3.1),
Y <- y,
Y = [1.0,2.0,3.1].
:- end_tests(real).

10
packages/real/pack.pl Normal file
View File

@ -0,0 +1,10 @@
name(real).
version('1.1.0').
title('Integrative statistics with R').
keywords([statistics,'R',bioinformatics,'machine learning']).
author( 'Nicos Angelopoulos', 'http://stoics.org.uk/~nicos' ).
author( 'Vitor Santos Costa', 'http:/www.dcc.fc.up.pt/~vsc' ).
packager( 'Nicos Angelopoulos', 'http://stoics.org.uk/~nicos' ).
maintainer( 'Nicos Angelopoulos', 'http://stoics.org.uk/~nicos' ).
home( 'http://stoics.org.uk/~nicos/sware/real' ).
download( 'http://stoics.org.uk/~nicos/sware/packs/real/real-*.tgz' ).

78
packages/real/pltotex.pl Normal file
View File

@ -0,0 +1,78 @@
:- module(pltotex,
[ pltotex/2,
pltotex/0
]).
:- use_module(library(doc_latex)).
:- use_module(library(main)).
:- use_module(library(error)).
:- use_module(library(apply)).
:- use_module(library(lists)).
:- asserta(user:file_search_path(foreign, .)).
pltotex(File, Options) :-
file_name_extension(_, txt, File), !,
tex_file(File, Out, Options),
doc_latex(File, Out,
[ stand_alone(false)
| Options
]).
pltotex(Lib, Options) :-
( file_name_extension(_, pl, Lib)
-> Spec = Lib
; atom_to_term(Lib, Spec, _)
),
absolute_file_name(Spec, File,
[ access(read),
file_type(prolog)
]),
tex_file(File, Out, Options),
user:use_module(File), % we want the operators in user
doc_latex(File, Out,
[ stand_alone(false)
| Options
]).
tex_file(_, TeXFile, Options) :-
option(out(Base), Options), !,
file_name_extension(Base, tex, TeXFile).
tex_file(File, TeXFile, _) :-
file_base_name(File, Local),
file_name_extension(Base0, _, Local),
strip(Base0, 0'_, Base),
file_name_extension(Base, tex, TeXFile).
strip(In, Code, Out) :-
atom_codes(In, Codes0),
delete(Codes0, Code, Codes),
atom_codes(Out, Codes).
%% pltotex
%
% Usage: pl -q -s pltotex.pl -g pltotex -- file ...
pltotex :-
main.
main(Argv) :-
partition(is_option, Argv, OptArgs, Files),
maplist(to_option, OptArgs, Options),
maplist(process_file(Options), Files).
is_option(Arg) :-
sub_atom(Arg, 0, _, _, --).
to_option('--section', section_level(section)) :- !.
to_option('--subsection', section_level(subsection)) :- !.
to_option('--subsubsection', section_level(subsubsection)) :- !.
to_option(Arg, Option) :-
atom_concat(--, Opt, Arg),
sub_atom(Opt, B, _, A, =), !,
sub_atom(Opt, 0, B, _, Name),
sub_atom(Opt, _, A, 0, Value),
Option =.. [Name, Value].
process_file(Options, File) :-
pltotex(File, Options).

View File

@ -0,0 +1,26 @@
/*--------------------------------------------------------------------------
* This file is autogenerated from rconfig.h.cmake
* during the cmake configuration of your project. If you need to make changes
* edit the original file NOT THIS FILE.
* --------------------------------------------------------------------------*/
#ifndef RCONFIG_H
#define RCONFIG_H
/* Define to 1 if you have the <alloca.h> header file. */
#ifndef HAVE_R_H
#cmakedefine HAVE_R_H ${HAVE_R_H}
#endif
/* Define to 1 if you have the <alloca.h> header file. */
#ifndef HAVE_R_EMBEDDED_H
#cmakedefine HAVE_R_EMBEDDED_H ${HAVE_R_EMBEDDED_H}
#endif
/* Define to 1 if you have the <alloca.h> header file. */
#ifndef HAVE_R_INTERFACE_H
#cmakedefine HAVE_R_INTERFACE_H ${HAVE_R_INTERFACE_H}
#endif
#endif

View File

@ -0,0 +1,26 @@
/*--------------------------------------------------------------------------
* This file is autogenerated from rconfig.h.cmake
* during the cmake configuration of your project. If you need to make changes
* edit the original file NOT THIS FILE.
* --------------------------------------------------------------------------*/
#ifndef RCONFIG_H
#define RCONFIG_H
/* Define to 1 if you have the <alloca.h> header file. */
#ifndef HAVE_R_H
#undef HAVE_R_H
#endif
/* Define to 1 if you have the <alloca.h> header file. */
#ifndef HAVE_R_EMBEDDED_H
#undef HAVE_R_EMBEDDED_H
#endif
/* ,Define to 1 if you have the <alloca.h> header file. */
#ifndef HAVE_R_INTERFACE_H
#undef HAVE_R_INTERFACE_H
#endif
#endif

2395
packages/real/real.c Normal file

File diff suppressed because it is too large Load Diff

39
packages/real/real.doc Normal file
View File

@ -0,0 +1,39 @@
\documentclass[11pt]{article}
\usepackage{times}
\usepackage{pl}
\usepackage{html}
\sloppy
\makeindex
\onefile
\htmloutput{.} % Output directory
\htmlmainfile{real} % Main document file
\bodycolor{white} % Page colour
\begin{document}
\title{SWI/YAP Prolog interface to R}
\author{Nicos Angelopoulos \\
V\'{\i}tor Santos Costa \\
Jan Wielemaker
}
\maketitle
\begin{abstract}
This package contains an interface to
\url[The R Project for Statistical Computing]{http://www.r-project.org/}
\end{abstract}
\pagebreak
\tableofcontents
\vfill
\vfill
\newpage
\input{libreal.tex}
\end{document}

68
packages/real/real.h Normal file
View File

@ -0,0 +1,68 @@
#include <Rembedded.h>
#include <R.h>
#include <Rinternals.h>
#include <Rdefines.h>
#include <R_ext/Parse.h>
#include <YapInterface.h>
#include <c_interface.h>
#define BUFSIZE 256
typedef unsigned int PL_Type;
#define PL_Nil 0
#define PL_Var 1
#define PL_Atom 2
#define PL_Appl 3
#define PL_Pair 4
#define PL_Int 5
#define PL_Float 6
#define PL_DbRef 7
#define PL_Unknown 8
typedef enum {
r_undefined,
r_double,
r_int,
r_character
} r_basic_types;
typedef struct
{
r_basic_types type;
union {
int int_val;
double double_val;
char *char_val;
} real_u;
} list_cell;
typedef struct
{
int size;
int nDims;
int dims[BUFSIZE];
list_cell values[BUFSIZE];
} list;
#define real_Int 1
#define real_Float 2
#define real_Char 3
#define real_Bool 4
#define real_ty_Vector 1
#define real_ty_Matrix 2
#define real_ty_List 3
#define real_ty_Array 4 //not used, yet
extern void init_R(void);
extern void end_R(void);
extern void send_command(char * expression);
extern int set_list_values(void);
extern int set_vec_values(void);
extern int set_array_values(void);
extern SEXP process_expression(char * expression);
extern YAP_Term sexp_pl(SEXP s);

1157
packages/real/real.pl Executable file

File diff suppressed because it is too large Load Diff