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