Search found 283 matches

by Martin Meyer
25 Mar 2021 20:46
Forum: Visual Prolog
Topic: From string to integer
Replies: 8
Views: 305

Re: From string to integer

Correct, integers can be negative. The language accepted in the example is but extremely simple. It accepts only number literals without leading signs. Optional leading signs would make the example more complicated. Signed numbers are usually implemented in parsers through unary functions " - &...
by Martin Meyer
25 Mar 2021 14:00
Forum: Visual Prolog
Topic: From string to integer
Replies: 8
Views: 305

Re: From string to integer

Yes, walk through the code by the debugger. Study the VIP Language Reference and tutorials. Doing so you will quickly become used to write programs in VIP. One way to jump to required blocks depending on the expression would be (including some beautification): implement main class predicates tryCalc...
by Martin Meyer
19 Mar 2021 1:30
Forum: Visual Prolog
Topic: Einstein's Riddle
Replies: 3
Views: 194

Re: Einstein's Riddle

An add-on remark from me: ISO Prolog style variables formerly had the type of "reference domains" in Visual Prolog. Thomas explains a way in which these variables can be emulated in current Visual Prolog in the Tutorial How To Remove Reference Domains from a Project . By the method explain...
by Martin Meyer
2 Nov 2020 16:26
Forum: Visual Prolog
Topic: Questions about family 1
Replies: 2
Views: 1177

Re: Questions about family 1

Hello Bo Cong, the pictures you have posted do not match. The 1st one shows an exe directory containing the usual files. In the 2nd pic the exe directory seems to be messed up: The usual files are missing and *.pack and *.ph files should better not be placed in the exe (= "executables") di...
by Martin Meyer
4 Jul 2020 10:31
Forum: Visual Prolog
Topic: Question about example in A Beginner's Guide to Visual Prolog
Replies: 8
Views: 3440

Re: Question about example in A Beginner's Guide to Visual Prolog

The recursion is not the relevant point for your question " how do outputs propagate ". When I remove the recursion from the example, the "propagation" becomes more obvious. The situation of the outermost call then is: class predicates add1 : (integer*, integer* [out]). clauses a...
by Martin Meyer
4 Jul 2020 2:16
Forum: Visual Prolog
Topic: Question about example in A Beginner's Guide to Visual Prolog
Replies: 8
Views: 3440

Re: Question about example in A Beginner's Guide to Visual Prolog

What you call "assignment" and "comparison" is in Visual Prolog (and any Prolog) accomplished by nothing else but the unification of terms. Formally speaking: A variable can be, and can only be, bound by a unification of terms. A unification can succeed or fail. Binding a variabl...
by Martin Meyer
3 Jul 2020 14:29
Forum: Visual Prolog
Topic: Replace nulls in ::string
Replies: 6
Views: 3041

Re: Replace nulls in ::string

@Chris: For the learning curve check the implementation of fromMsStringSeq/1-> in windowsAPI.pro, it is done there more efficient than in my code.
by Martin Meyer
3 Jul 2020 13:59
Forum: Visual Prolog
Topic: Replace nulls in ::string
Replies: 6
Views: 3041

Re: Replace nulls in ::string

ah, thank you Thomas! So, we should do it like class predicates getLogicalDriveStrings : (charCount BufLen, unsigned Result [out]) -> string_list Str_list. clauses getLogicalDriveStrings(BufLen, Result) = windowsAPI::fromMsStringSeq(uncheckedConvert(windowsAPI::msStringSeq, Buf)) :- Buf = memory::al...
by Martin Meyer
2 Jul 2020 18:41
Forum: Visual Prolog
Topic: Replace nulls in ::string
Replies: 6
Views: 3041

Re: Replace nulls in ::string

Maybe there is a problem in memory::getString/2-> . Because when I replaced it by my own version, it has worked out: open core class predicates getLogicalDriveStrings : (charCount BufLen, unsigned Result [out]) -> string_list Str_list. clauses getLogicalDriveStrings(BufLen, Result) = getLogicalDrive...
by Martin Meyer
30 Jun 2020 22:18
Forum: Visual Prolog
Topic: Question about example in A Beginner's Guide to Visual Prolog
Replies: 8
Views: 3440

Re: Question about example in A Beginner's Guide to Visual Prolog

To track the computation you could (besides using the debugger) simply insert calls to write into the code which will produce a 'log'. To try that paste the below in file main.pro of a new console project: class listmanager predicates add1 : (integer*, integer* [out]). end class listmanager %--- imp...
by Martin Meyer
30 Jun 2020 17:13
Forum: Visual Prolog
Topic: Question about example in A Beginner's Guide to Visual Prolog
Replies: 8
Views: 3440

Re: Question about example in A Beginner's Guide to Visual Prolog

That means, variables can be bound solely through the head of a called clause, without having to use " = ". Like for example in: class predicates inverse : (integer, integer [out]). clauses inverse(Num, -Num). clauses run() :- inverse(3, X), stdio::write("X = ", X). Predicate inv...
by Martin Meyer
30 Jun 2020 16:43
Forum: Visual Prolog
Topic: Question about example in A Beginner's Guide to Visual Prolog
Replies: 8
Views: 3440

Re: Question about example in A Beginner's Guide to Visual Prolog

The conceptual behavior, which Thomas has explained in particular, is also described in the Language Reference in general. It often helps me to look up things there. The reference says that unification takes place in two different situations: When a predicate is called the arguments from the call ar...
by Martin Meyer
4 Jun 2020 13:03
Forum: Visual Prolog
Topic: Prolog - school project
Replies: 1
Views: 2549

Re: Prolog - school project

Hi Kim, very different Prolog implementations exist. Only some of them are modular within a framework of object-oriented programming. Visual Prolog gives a fine example of objects and modules in a programming language. It comes with a programming environment for developing programs. The environment ...
by Martin Meyer
26 May 2020 21:39
Forum: Visual Prolog
Topic: Wishlist Item
Replies: 6
Views: 4070

Re: Wishlist Item

In my class bitAddOn I give all bit counts type positive or in some cases positiveOptional . For example I have predicates getLowBitPos64 : (unsigned64 X) -> positiveOptional BitPosition. % @short Returns the position of the lowest 1-bit % @end where a result of -1 means that there is no 1-bit in X ...
by Martin Meyer
24 May 2020 21:50
Forum: Visual Prolog
Topic: Domains specification in both .i and .cl files
Replies: 3
Views: 3021

Re: Domains specification in both .i and .cl files

Hello Harrison, defining domain expressionDOM in the face interface it works without the helper class: interface face domains expressionDOM = smiling; frowning. predicates setExpression : (expressionDOM). getExpression : () -> expressionDOM. end interface face %--- class face : face constructors new...