| 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2 | % |
|---|
| 3 | % Logtalk - Object oriented extension to Prolog |
|---|
| 4 | % Release 2.9.0 |
|---|
| 5 | % |
|---|
| 6 | % configuration file for PrologII+ 4.5 |
|---|
| 7 | % |
|---|
| 8 | % last updated: August 24, 2000 |
|---|
| 9 | % |
|---|
| 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | :- set_prolog_flag(unknown, :fail). |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | abort :- |
|---|
| 17 | block_exit(0). |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 22 | % |
|---|
| 23 | % ISO Prolog Standard predicates that we must define because they are |
|---|
| 24 | % not built-in |
|---|
| 25 | % |
|---|
| 26 | % add a clause for lgt_iso_predicate/1 declaring each ISO predicate that |
|---|
| 27 | % we must define; there must be at least one clause for this predicate |
|---|
| 28 | % whose call should fail if we don't define any ISO predicates |
|---|
| 29 | % |
|---|
| 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | % lgt_iso_predicate(?callable). |
|---|
| 34 | |
|---|
| 35 | lgt_iso_predicate(_) :- |
|---|
| 36 | fail. |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 41 | % |
|---|
| 42 | % predicate properties |
|---|
| 43 | % |
|---|
| 44 | % this predicate must return at least static, dynamic and built_in |
|---|
| 45 | % properties for an existing predicate |
|---|
| 46 | % |
|---|
| 47 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | % lgt_predicate_property(+callable, ?predicate_property) |
|---|
| 51 | |
|---|
| 52 | lgt_predicate_property(Pred, built_in) :- |
|---|
| 53 | predefined(Pred). |
|---|
| 54 | |
|---|
| 55 | lgt_predicate_property(_, dynamic). |
|---|
| 56 | |
|---|
| 57 | lgt_predicate_property(_, static) :- |
|---|
| 58 | fail. |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 63 | % |
|---|
| 64 | % metapredicates |
|---|
| 65 | % |
|---|
| 66 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | % forall(+callable, +callble) |
|---|
| 70 | |
|---|
| 71 | forall(Generate, Test) :- |
|---|
| 72 | \+ call((Generate, \+ call(Test))). |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | % lgt_call/2-8 |
|---|
| 76 | % |
|---|
| 77 | % use these definitions only if your compiler does |
|---|
| 78 | % not provide call/1-8 as built-in predicates |
|---|
| 79 | |
|---|
| 80 | lgt_call(F, A) :- |
|---|
| 81 | Call =.. [F, A], |
|---|
| 82 | call(Call). |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | lgt_call(F, A1, A2) :- |
|---|
| 86 | Call =.. [F, A1, A2], |
|---|
| 87 | call(Call). |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | lgt_call(F, A1, A2, A3) :- |
|---|
| 91 | Call =.. [F, A1, A2, A3], |
|---|
| 92 | call(Call). |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | lgt_call(F, A1, A2, A3, A4) :- |
|---|
| 96 | Call =.. [F, A1, A2, A3, A4], |
|---|
| 97 | call(Call). |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | lgt_call(F, A1, A2, A3, A4, A5) :- |
|---|
| 101 | Call =.. [F, A1, A2, A3, A4, A5], |
|---|
| 102 | call(Call). |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | lgt_call(F, A1, A2, A3, A4, A5, A6) :- |
|---|
| 106 | Call =.. [F, A1, A2, A3, A4, A5, A6], |
|---|
| 107 | call(Call). |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | lgt_call(F, A1, A2, A3, A4, A5, A6, A7) :- |
|---|
| 111 | Call =.. [F, A1, A2, A3, A4, A5, A6, A7], |
|---|
| 112 | call(Call). |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | % lgt_once/2-8 |
|---|
| 116 | % |
|---|
| 117 | % if your compiler provides call/1-8 as built-in |
|---|
| 118 | % predicates rewrite these definitions using call(...), !. |
|---|
| 119 | |
|---|
| 120 | lgt_once(F, A) :- |
|---|
| 121 | Call =.. [F, A], |
|---|
| 122 | once(Call). |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | lgt_once(F, A1, A2) :- |
|---|
| 126 | Call =.. [F, A1, A2], |
|---|
| 127 | once(Call). |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | lgt_once(F, A1, A2, A3) :- |
|---|
| 131 | Call =.. [F, A1, A2, A3], |
|---|
| 132 | once(Call). |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | lgt_once(F, A1, A2, A3, A4) :- |
|---|
| 136 | Call =.. [F, A1, A2, A3, A4], |
|---|
| 137 | once(Call). |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | lgt_once(F, A1, A2, A3, A4, A5) :- |
|---|
| 141 | Call =.. [F, A1, A2, A3, A4, A5], |
|---|
| 142 | once(Call). |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | lgt_once(F, A1, A2, A3, A4, A5, A6) :- |
|---|
| 146 | Call =.. [F, A1, A2, A3, A4, A5, A6], |
|---|
| 147 | once(Call). |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | lgt_once(F, A1, A2, A3, A4, A5, A6, A7) :- |
|---|
| 151 | Call =.. [F, A1, A2, A3, A4, A5, A6, A7], |
|---|
| 152 | once(Call). |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 157 | % |
|---|
| 158 | % file extension predicates |
|---|
| 159 | % |
|---|
| 160 | % these extensions are used by Logtalk load/compile predicates |
|---|
| 161 | % |
|---|
| 162 | % you may want to change the extension for Prolog files to match |
|---|
| 163 | % the one expected by your Prolog compiler |
|---|
| 164 | % |
|---|
| 165 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | % lgt_file_extension(?atom, ?atom) |
|---|
| 169 | |
|---|
| 170 | lgt_file_extension(logtalk, '.lgt'). |
|---|
| 171 | lgt_file_extension(prolog, '.pl'). |
|---|
| 172 | lgt_file_extension(xml, '.xml'). |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 177 | % |
|---|
| 178 | % default compiler options |
|---|
| 179 | % |
|---|
| 180 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | % lgt_default_compiler_option(?atom, ?atom) |
|---|
| 184 | % |
|---|
| 185 | % default values for all compiler options |
|---|
| 186 | |
|---|
| 187 | lgt_default_compiler_option(iso_initialization_dir, true). |
|---|
| 188 | |
|---|
| 189 | lgt_default_compiler_option(xml, on). |
|---|
| 190 | lgt_default_compiler_option(xsl, 'lgtxml.xsl'). |
|---|
| 191 | |
|---|
| 192 | lgt_default_compiler_option(unknown, warning). |
|---|
| 193 | lgt_default_compiler_option(misspelt, warning). |
|---|
| 194 | lgt_default_compiler_option(singletons, warning). |
|---|
| 195 | lgt_default_compiler_option(lgtredef, warning). |
|---|
| 196 | lgt_default_compiler_option(plredef, silent). |
|---|
| 197 | |
|---|
| 198 | lgt_default_compiler_option(report, on). |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 203 | % |
|---|
| 204 | % list predicates |
|---|
| 205 | % |
|---|
| 206 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | lgt_append([], List, List). |
|---|
| 210 | lgt_append([Head| Tail], List, [Head| Tail2]) :- |
|---|
| 211 | lgt_append(Tail, List, Tail2). |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | lgt_member(Head, [Head| _]). |
|---|
| 215 | lgt_member(Head, [_| Tail]) :- |
|---|
| 216 | lgt_member(Head, Tail). |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | lgt_member_var(Var, [Head| _]) :- |
|---|
| 220 | Var == Head. |
|---|
| 221 | lgt_member_var(Var, [_| Tail]) :- |
|---|
| 222 | lgt_member_var(Var, Tail). |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | lgt_proper_list([]). |
|---|
| 226 | lgt_proper_list([_| List]) :- |
|---|
| 227 | lgt_proper_list(List). |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 232 | % |
|---|
| 233 | % file predicates |
|---|
| 234 | % |
|---|
| 235 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | % lgt_file_exists(+atom) |
|---|
| 239 | % |
|---|
| 240 | % see if a file exist in the current directory |
|---|
| 241 | |
|---|
| 242 | lgt_file_exists(File) :- |
|---|
| 243 | nonvar(File), |
|---|
| 244 | catch(open(File, :read, Stream), _, fail), |
|---|
| 245 | close(Stream). |
|---|
| 246 | |
|---|
| 247 | |
|---|
| 248 | % lgt_load_prolog_code(+atom) |
|---|
| 249 | % |
|---|
| 250 | % compile and load a Prolog file |
|---|
| 251 | |
|---|
| 252 | lgt_load_prolog_code(File) :- |
|---|
| 253 | reconsult(File), |
|---|
| 254 | write(File), |
|---|
| 255 | write(' loaded'), |
|---|
| 256 | nl. |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | |
|---|
| 260 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 261 | % |
|---|
| 262 | % sorting predicates |
|---|
| 263 | % |
|---|
| 264 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 265 | |
|---|
| 266 | |
|---|
| 267 | % lgt_keysort(+list, -list) |
|---|
| 268 | |
|---|
| 269 | lgt_keysort(List, Sorted) :- |
|---|
| 270 | keysort(List, Sorted). |
|---|
| 271 | |
|---|
| 272 | |
|---|
| 273 | % lgt_sort( +List, -Sorted ) |
|---|
| 274 | |
|---|
| 275 | lgt_sort(List, Sorted) :- |
|---|
| 276 | sort(List, Sorted). |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | |
|---|
| 280 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 281 | % |
|---|
| 282 | % time and date predicates |
|---|
| 283 | % |
|---|
| 284 | % if your Prolog compiler does not provide access to the operating system |
|---|
| 285 | % time and date just write dummy definitions |
|---|
| 286 | % |
|---|
| 287 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | % lgt_current_date(?Year, ?Month, ?Day) |
|---|
| 291 | |
|---|
| 292 | lgt_current_date(Year, Month, Day) :- |
|---|
| 293 | date(Day, Month, Year, _). |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | % lgt_current_time(?Hours, ?Mins, ?Secs) |
|---|
| 297 | |
|---|
| 298 | lgt_current_time(Hours, Mins, Secs) :- |
|---|
| 299 | time(Hours, Mins, Secs). |
|---|
| 300 | |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 304 | % |
|---|
| 305 | % timing predicate |
|---|
| 306 | % |
|---|
| 307 | % if your Prolog compiler does not provide access to a timing predicate |
|---|
| 308 | % just write dummy definition |
|---|
| 309 | % |
|---|
| 310 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | % lgt_cpu_time(-Seconds) |
|---|
| 314 | |
|---|
| 315 | lgt_cpu_time(Seconds) :- |
|---|
| 316 | cpu_time(Milliseconds), |
|---|
| 317 | Seconds is Milliseconds/1000.0. |
|---|
| 318 | |
|---|
| 319 | |
|---|
| 320 | |
|---|
| 321 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 322 | % |
|---|
| 323 | % comparison predicate |
|---|
| 324 | % |
|---|
| 325 | % the usual compare/3 definition |
|---|
| 326 | % |
|---|
| 327 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | % compare(?atom, @term, @term) |
|---|
| 331 | |
|---|
| 332 | compare(<, X, Y) :- |
|---|
| 333 | X @< Y, !. |
|---|
| 334 | |
|---|
| 335 | compare(=, X, Y) :- |
|---|
| 336 | X == Y, !. |
|---|
| 337 | |
|---|
| 338 | compare(>, X, Y) :- |
|---|
| 339 | X @> Y. |
|---|
| 340 | |
|---|
| 341 | |
|---|
| 342 | |
|---|
| 343 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 344 | % |
|---|
| 345 | % end! |
|---|
| 346 | % |
|---|
| 347 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|