Did you know ... Search Documentation:
Pack logtalk -- logtalk-3.86.0/examples/points/SCRIPT.txt

This file is part of Logtalk https://logtalk.org/ SPDX-FileCopyrightText: 1998-2023 Paulo Moura <pmoura@logtalk.org> SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

% start by loading the example and the required library files:

| ?- logtalk_load(points(loader)). ...

% let's start with a simple point:

| ?- point::new(Point, [position-(1, 3)]), Point::(print, move(7, 4), print).

p1 @ (1, 3) p1 @ (7, 4)

Point = p1 ?

yes

% same problem but with bounds on coordinate values:

| ?- bounded_point::new(Point, [position-(1, 3), bounds(x)-(0, 13), bounds(y)-(-7, 7)]), Point::(print, move(7, 4), print).

bounds(x) : 0,13 bounds(y) : -7,7 bp2 @ (1, 3) bounds(x) : 0,13 bounds(y) : -7,7 bp2 @ (7, 4)

Point = bp2 ?

yes

% same problem but storing the history of coordinate values:

| ?- history_point::new(Point, [position-(1, 3)]), Point::(print, move(7, 4), print).

location history: [] hp3 @ (1, 3) location history: [(1,3)] hp3 @ (7, 4)

Point = hp3 ?

yes

% same problem but with bounds on coordinate values and storing past values:

| ?- bounded_history_point::new(Point, [position-(1, 3), bounds(x)-(0, 13), bounds(y)-(-7, 7)]), Point::(print, move(7, 4), print).

bounds(x) : 0,13 bounds(y) : -7,7 location history: [] bhp4 @ (1, 3) bounds(x) : 0,13 bounds(y) : -7,7 location history: [(1,3)] bhp4 @ (7, 4)

Point = bhp4 ?

yes

% clean up instances:

| ?- point::delete_all, bounded_point::delete_all, history_point::delete_all, bounded_history_point::delete_all. yes