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