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