| 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2 | % |
|---|
| 3 | % Logtalk - Object oriented extension to Prolog |
|---|
| 4 | % Release 2.21.0 |
|---|
| 5 | % |
|---|
| 6 | % configuration file for CIAO Prolog 1.8p2 |
|---|
| 7 | % |
|---|
| 8 | % last updated: July 17, 2004 |
|---|
| 9 | % |
|---|
| 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | :- use_package(iso). |
|---|
| 14 | |
|---|
| 15 | :- use_package(runtime_ops). |
|---|
| 16 | :- use_package(hiord). |
|---|
| 17 | |
|---|
| 18 | :- use_module(library(compiler)). |
|---|
| 19 | :- use_module(library(system)). |
|---|
| 20 | :- use_module(library(prolog_sys)). |
|---|
| 21 | :- use_module(library(sort)). |
|---|
| 22 | |
|---|
| 23 | :- include(engine(builtin_exports)). |
|---|
| 24 | |
|---|
| 25 | :- set_prolog_flag(multi_arity_warnings, off). |
|---|
| 26 | |
|---|
| 27 | :- op(1200, xfx,[(-->)]). |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 32 | % |
|---|
| 33 | % ISO Prolog Standard predicates that we must define because they are |
|---|
| 34 | % not built-in |
|---|
| 35 | % |
|---|
| 36 | % add a clause for lgt_iso_predicate/1 declaring each ISO predicate that |
|---|
| 37 | % we must define; there must be at least one clause for this predicate |
|---|
| 38 | % whose call should fail if we don't define any ISO predicates |
|---|
| 39 | % |
|---|
| 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | % '$lgt_iso_predicate'(?callable). |
|---|
| 44 | |
|---|
| 45 | '$lgt_iso_predicate'(_) :- |
|---|
| 46 | fail. |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 51 | % |
|---|
| 52 | % predicate properties |
|---|
| 53 | % |
|---|
| 54 | % this predicate must return at least static, dynamic, and built_in |
|---|
| 55 | % properties for an existing predicate |
|---|
| 56 | % |
|---|
| 57 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | % '$lgt_predicate_property'(+callable, ?predicate_property) |
|---|
| 61 | |
|---|
| 62 | '$lgt_predicate_property'(Pred, built_in) :- |
|---|
| 63 | functor(Pred, Functor, Arity), |
|---|
| 64 | builtin_export(_, Functor, Arity, _). |
|---|
| 65 | |
|---|
| 66 | '$lgt_predicate_property'(Pred, built_in) :- |
|---|
| 67 | lgt_ciao_iso_builtin(Pred). |
|---|
| 68 | |
|---|
| 69 | '$lgt_predicate_property'(Pred, static) :- |
|---|
| 70 | predicate_property(Pred, compiled). |
|---|
| 71 | |
|---|
| 72 | '$lgt_predicate_property'(Pred, static) :- |
|---|
| 73 | functor(Pred, Functor, Arity), |
|---|
| 74 | atom_concat('user:', Functor, Functor2), |
|---|
| 75 | functor(Pred2, Functor2, Arity), |
|---|
| 76 | predicate_property(Pred2, compiled). |
|---|
| 77 | |
|---|
| 78 | '$lgt_predicate_property'(Pred, Prop) :- |
|---|
| 79 | predicate_property(Pred, Prop). |
|---|
| 80 | |
|---|
| 81 | '$lgt_predicate_property'(Pred, Prop) :- |
|---|
| 82 | functor(Pred, Functor, Arity), |
|---|
| 83 | atom_concat('user:', Functor, Functor2), |
|---|
| 84 | functor(Pred2, Functor2, Arity), |
|---|
| 85 | predicate_property(Pred2, Prop). |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | lgt_ciao_iso_builtin(write(_)). |
|---|
| 89 | lgt_ciao_iso_builtin(write(_, _)). |
|---|
| 90 | lgt_ciao_iso_builtin(writeq(_)). |
|---|
| 91 | lgt_ciao_iso_builtin(writeq(_, _)). |
|---|
| 92 | lgt_ciao_iso_builtin(write_canonical(_)). |
|---|
| 93 | lgt_ciao_iso_builtin(write_canonical(_, _)). |
|---|
| 94 | lgt_ciao_iso_builtin(write_term(_, _)). |
|---|
| 95 | lgt_ciao_iso_builtin(write_term(_, _, _)). |
|---|
| 96 | |
|---|
| 97 | lgt_ciao_iso_builtin(read(_)). |
|---|
| 98 | lgt_ciao_iso_builtin(read(_, _)). |
|---|
| 99 | lgt_ciao_iso_builtin(read_term(_, _)). |
|---|
| 100 | lgt_ciao_iso_builtin(read_term(_, _, _)). |
|---|
| 101 | |
|---|
| 102 | lgt_ciao_iso_builtin(open(_, _, _, _)). |
|---|
| 103 | lgt_ciao_iso_builtin(close(_, _)). |
|---|
| 104 | lgt_ciao_iso_builtin(stream_property(_, _)). |
|---|
| 105 | |
|---|
| 106 | lgt_ciao_iso_builtin(op(_, _, _)). |
|---|
| 107 | lgt_ciao_iso_builtin(current_op(_, _, _)). |
|---|
| 108 | |
|---|
| 109 | lgt_ciao_iso_builtin(_ \= _). |
|---|
| 110 | lgt_ciao_iso_builtin(once(_)). |
|---|
| 111 | lgt_ciao_iso_builtin(compound(_)). |
|---|
| 112 | lgt_ciao_iso_builtin(sub_atom(_, _, _, _, _)). |
|---|
| 113 | lgt_ciao_iso_builtin(unify_with_occurs_check(_, _)). |
|---|
| 114 | |
|---|
| 115 | lgt_ciao_iso_builtin(char_code(_, _)). |
|---|
| 116 | lgt_ciao_iso_builtin(atom_chars(_, _)). |
|---|
| 117 | lgt_ciao_iso_builtin(number_chars(_, _)). |
|---|
| 118 | lgt_ciao_iso_builtin(get_byte(_)). |
|---|
| 119 | lgt_ciao_iso_builtin(get_byte(_, _)). |
|---|
| 120 | lgt_ciao_iso_builtin(peek_byte(_)). |
|---|
| 121 | lgt_ciao_iso_builtin(peek_byte(_, _)). |
|---|
| 122 | lgt_ciao_iso_builtin(put_byte(_)). |
|---|
| 123 | lgt_ciao_iso_builtin(put_byte(_, _)). |
|---|
| 124 | lgt_ciao_iso_builtin(get_char(_)). |
|---|
| 125 | lgt_ciao_iso_builtin(get_char(_, _)). |
|---|
| 126 | lgt_ciao_iso_builtin(peek_char(_)). |
|---|
| 127 | lgt_ciao_iso_builtin(peek_char(_, _)). |
|---|
| 128 | lgt_ciao_iso_builtin(put_char(_)). |
|---|
| 129 | lgt_ciao_iso_builtin(put_char(_, _)). |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 134 | % |
|---|
| 135 | % metapredicates |
|---|
| 136 | % |
|---|
| 137 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | % forall(+callable, +callble) |
|---|
| 141 | |
|---|
| 142 | forall(Generate, Test) :- |
|---|
| 143 | \+ call((Generate, \+ call(Test))). |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | % retractall(+callable) -- built-in |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | % lgt_call/2-8 |
|---|
| 150 | % |
|---|
| 151 | % if your compiler provides call/1-8 as built-in |
|---|
| 152 | % predicates rewrite these definitions using call(...). |
|---|
| 153 | |
|---|
| 154 | '$lgt_call'(F, A) :- |
|---|
| 155 | call(F, A). |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | '$lgt_call'(F, A1, A2) :- |
|---|
| 159 | call(F, A1, A2). |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | '$lgt_call'(F, A1, A2, A3) :- |
|---|
| 163 | call(F, A1, A2, A3). |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | '$lgt_call'(F, A1, A2, A3, A4) :- |
|---|
| 167 | call(F, A1, A2, A3, A4). |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | '$lgt_call'(F, A1, A2, A3, A4, A5) :- |
|---|
| 171 | call(F, A1, A2, A3, A4, A5). |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | '$lgt_call'(F, A1, A2, A3, A4, A5, A6) :- |
|---|
| 175 | call(F, A1, A2, A3, A4, A5, A6). |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | '$lgt_call'(F, A1, A2, A3, A4, A5, A6, A7) :- |
|---|
| 179 | call(F, A1, A2, A3, A4, A5, A6, A7). |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | % lgt_once/2-8 |
|---|
| 183 | % |
|---|
| 184 | % if your compiler provides call/1-8 as built-in |
|---|
| 185 | % predicates rewrite these definitions using call(...), !. |
|---|
| 186 | |
|---|
| 187 | '$lgt_once'(F, A) :- |
|---|
| 188 | call(F, A), |
|---|
| 189 | !. |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | '$lgt_once'(F, A1, A2) :- |
|---|
| 193 | call(F, A1, A2), |
|---|
| 194 | !. |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | '$lgt_once'(F, A1, A2, A3) :- |
|---|
| 198 | call(F, A1, A2, A3), |
|---|
| 199 | !. |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | '$lgt_once'(F, A1, A2, A3, A4) :- |
|---|
| 203 | call(F, A1, A2, A3, A4), |
|---|
| 204 | !. |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | '$lgt_once'(F, A1, A2, A3, A4, A5) :- |
|---|
| 208 | call(F, A1, A2, A3, A4, A5), |
|---|
| 209 | !. |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | '$lgt_once'(F, A1, A2, A3, A4, A5, A6) :- |
|---|
| 213 | call(F, A1, A2, A3, A4, A5, A6), |
|---|
| 214 | !. |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | '$lgt_once'(F, A1, A2, A3, A4, A5, A6, A7) :- |
|---|
| 218 | call(F, A1, A2, A3, A4, A5, A6, A7), |
|---|
| 219 | !. |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 224 | % |
|---|
| 225 | % Prolog built-in metapredicates |
|---|
| 226 | % |
|---|
| 227 | % (excluding ISO Prolog Standard metapredicates) |
|---|
| 228 | % |
|---|
| 229 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | % '$lgt_pl_metapredicate'(?callable). |
|---|
| 233 | |
|---|
| 234 | '$lgt_pl_metapredicate'(_) :- |
|---|
| 235 | fail. |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 240 | % |
|---|
| 241 | % file extension predicates |
|---|
| 242 | % |
|---|
| 243 | % these extensions are used by Logtalk load/compile predicates |
|---|
| 244 | % |
|---|
| 245 | % you may want to change the extension for Prolog files to match |
|---|
| 246 | % the one expected by your Prolog compiler |
|---|
| 247 | % |
|---|
| 248 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | % '$lgt_file_extension'(?atom, ?atom) |
|---|
| 252 | |
|---|
| 253 | '$lgt_file_extension'(metafile, '.mlgt'). |
|---|
| 254 | '$lgt_file_extension'(logtalk, '.lgt'). |
|---|
| 255 | '$lgt_file_extension'(prolog, '.pl'). |
|---|
| 256 | '$lgt_file_extension'(xml, '.xml'). |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | |
|---|
| 260 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 261 | % |
|---|
| 262 | % default flag values |
|---|
| 263 | % |
|---|
| 264 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 265 | |
|---|
| 266 | |
|---|
| 267 | % '$lgt_default_flag'(?atom, ?atom) |
|---|
| 268 | % |
|---|
| 269 | % default values for all flags |
|---|
| 270 | |
|---|
| 271 | '$lgt_default_flag'(iso_initialization_dir, true). |
|---|
| 272 | |
|---|
| 273 | '$lgt_default_flag'(xml, on). |
|---|
| 274 | '$lgt_default_flag'(xsl, 'lgtxml.xsl'). |
|---|
| 275 | '$lgt_default_flag'(xmlspec, dtd). |
|---|
| 276 | '$lgt_default_flag'(doctype, local). |
|---|
| 277 | |
|---|
| 278 | '$lgt_default_flag'(unknown, warning). |
|---|
| 279 | '$lgt_default_flag'(misspelt, warning). |
|---|
| 280 | '$lgt_default_flag'(singletons, warning). |
|---|
| 281 | '$lgt_default_flag'(lgtredef, warning). |
|---|
| 282 | '$lgt_default_flag'(plredef, silent). |
|---|
| 283 | '$lgt_default_flag'(portability, silent). |
|---|
| 284 | |
|---|
| 285 | '$lgt_default_flag'(report, on). |
|---|
| 286 | |
|---|
| 287 | '$lgt_default_flag'(smart_compilation, off). |
|---|
| 288 | |
|---|
| 289 | '$lgt_default_flag'(startup_message, flags). |
|---|
| 290 | |
|---|
| 291 | '$lgt_default_flag'(underscore_vars, singletons). |
|---|
| 292 | |
|---|
| 293 | '$lgt_default_flag'(code_prefix, ''). |
|---|
| 294 | |
|---|
| 295 | '$lgt_default_flag'(debug, off). |
|---|
| 296 | '$lgt_default_flag'(supports_break_predicate, false). |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 301 | % |
|---|
| 302 | % list predicates |
|---|
| 303 | % |
|---|
| 304 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 305 | |
|---|
| 306 | |
|---|
| 307 | '$lgt_append'([], List, List). |
|---|
| 308 | '$lgt_append'([Head| Tail], List, [Head| Tail2]) :- |
|---|
| 309 | '$lgt_append'(Tail, List, Tail2). |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | '$lgt_member'(Head, List) :- |
|---|
| 313 | member(Head, List). |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | '$lgt_member_var'(V, [H| _]) :- |
|---|
| 317 | V == H. |
|---|
| 318 | '$lgt_member_var'(V, [_| T]) :- |
|---|
| 319 | '$lgt_member_var'(V, T). |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | '$lgt_proper_list'(List) :- |
|---|
| 323 | list(List). |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | '$lgt_reverse'(List, Reversed) :- |
|---|
| 327 | '$lgt_reverse'(List, [], Reversed, Reversed). |
|---|
| 328 | |
|---|
| 329 | '$lgt_reverse'([], Reversed, Reversed, []). |
|---|
| 330 | '$lgt_reverse'([Head| Tail], List, Reversed, [_| Bound]) :- |
|---|
| 331 | '$lgt_reverse'(Tail, [Head| List], Reversed, Bound). |
|---|
| 332 | |
|---|
| 333 | |
|---|
| 334 | |
|---|
| 335 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 336 | % |
|---|
| 337 | % file predicates |
|---|
| 338 | % |
|---|
| 339 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | % '$lgt_file_exists'(+atom) |
|---|
| 343 | % |
|---|
| 344 | % see if a file exist in the current directory |
|---|
| 345 | |
|---|
| 346 | '$lgt_file_exists'(File) :- |
|---|
| 347 | file_exists(File). |
|---|
| 348 | |
|---|
| 349 | |
|---|
| 350 | % '$lgt_load_prolog_code'(+atom) |
|---|
| 351 | % |
|---|
| 352 | % compile and load a Prolog file |
|---|
| 353 | |
|---|
| 354 | '$lgt_load_prolog_code'(File) :- |
|---|
| 355 | set_prolog_flag(multi_arity_warnings, off), |
|---|
| 356 | ensure_loaded(File). |
|---|
| 357 | |
|---|
| 358 | |
|---|
| 359 | % '$lgt_compare_file_mtimes'(?atom, +atom, +atom) |
|---|
| 360 | % |
|---|
| 361 | % compare file modification times |
|---|
| 362 | |
|---|
| 363 | '$lgt_compare_file_mtimes'(Result, File1, File2) :- |
|---|
| 364 | file_property(File1, mod_time(Time1)), |
|---|
| 365 | file_property(File2, mod_time(Time2)), |
|---|
| 366 | compare(Result, Time1, Time2). |
|---|
| 367 | |
|---|
| 368 | |
|---|
| 369 | |
|---|
| 370 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 371 | % |
|---|
| 372 | % sorting predicate |
|---|
| 373 | % |
|---|
| 374 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 375 | |
|---|
| 376 | |
|---|
| 377 | % '$lgt_keysort'(+list, -list) |
|---|
| 378 | |
|---|
| 379 | '$lgt_keysort'(List, Sorted) :- |
|---|
| 380 | keysort(List, Sorted). |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | % '$lgt_sort'(+list, -list) |
|---|
| 384 | |
|---|
| 385 | '$lgt_sort'(List, Sorted) :- |
|---|
| 386 | sort(List, Sorted). |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 391 | % |
|---|
| 392 | % time and date predicates |
|---|
| 393 | % |
|---|
| 394 | % if your Prolog compiler does not provide access to the operating system |
|---|
| 395 | % time and date just write dummy definitions |
|---|
| 396 | % |
|---|
| 397 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | % '$lgt_current_date'(?Year, ?Month, ?Day) |
|---|
| 401 | |
|---|
| 402 | '$lgt_current_date'(Year, Month, Day) :- |
|---|
| 403 | datime(_, Year, Month, Day, _, _, _, _, _). |
|---|
| 404 | |
|---|
| 405 | |
|---|
| 406 | % '$lgt_current_time'(?Hours, ?Mins, ?Secs) |
|---|
| 407 | |
|---|
| 408 | '$lgt_current_time'(Hours, Mins, Secs) :- |
|---|
| 409 | datime(_, _, _, _, Hours, Mins, Secs, _, _). |
|---|
| 410 | |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 414 | % |
|---|
| 415 | % timing predicate |
|---|
| 416 | % |
|---|
| 417 | % if your Prolog compiler does not provide access to a timing predicate |
|---|
| 418 | % just write dummy definition |
|---|
| 419 | % |
|---|
| 420 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 421 | |
|---|
| 422 | |
|---|
| 423 | % '$lgt_cpu_time'(-Seconds) |
|---|
| 424 | |
|---|
| 425 | '$lgt_cpu_time'(Seconds) :- |
|---|
| 426 | statistics(runtime, [Miliseconds| _]), |
|---|
| 427 | Seconds is Miliseconds / 1000. |
|---|
| 428 | |
|---|
| 429 | |
|---|
| 430 | |
|---|
| 431 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 432 | % |
|---|
| 433 | % comparison predicate |
|---|
| 434 | % |
|---|
| 435 | % the usual compare/3 definition |
|---|
| 436 | % |
|---|
| 437 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 438 | |
|---|
| 439 | |
|---|
| 440 | % compare(?atom, @term, @term) -- built-in |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | |
|---|
| 444 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 445 | % |
|---|
| 446 | % callable predicate |
|---|
| 447 | % |
|---|
| 448 | % the usual callable/1 definition |
|---|
| 449 | % |
|---|
| 450 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | % callable(@term) -- built-in |
|---|
| 454 | |
|---|
| 455 | |
|---|
| 456 | |
|---|
| 457 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 458 | % |
|---|
| 459 | % read character predicate |
|---|
| 460 | % |
|---|
| 461 | % read a single character echoing it and writing a newline after |
|---|
| 462 | % |
|---|
| 463 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 464 | |
|---|
| 465 | |
|---|
| 466 | '$lgt_read_single_char'(Char) :- |
|---|
| 467 | get_char(Char). |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 472 | % |
|---|
| 473 | % pretty print a term by naming its free variables |
|---|
| 474 | % (avoid instantiating variables in term by using double negation if necessary) |
|---|
| 475 | % |
|---|
| 476 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 477 | |
|---|
| 478 | |
|---|
| 479 | '$lgt_pretty_print_vars'(Stream, Term) :- |
|---|
| 480 | \+ \+ ( |
|---|
| 481 | numbervars(Term, 0, _), |
|---|
| 482 | write_term(Stream, Term, [numbervars(true)])). |
|---|
| 483 | |
|---|
| 484 | |
|---|
| 485 | '$lgt_pretty_print_vars_quoted'(Stream, Term) :- |
|---|
| 486 | \+ \+ ( |
|---|
| 487 | numbervars(Term, 0, _), |
|---|
| 488 | write_term(Stream, Term, [numbervars(true), quoted(true)])). |
|---|
| 489 | |
|---|
| 490 | |
|---|
| 491 | |
|---|
| 492 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 493 | % |
|---|
| 494 | % end! |
|---|
| 495 | % |
|---|
| 496 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|