Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • \$\begingroup\$ Using SWI-Prolog, you could shorten the atom_codes part by using the backquotes which delimit string codes (so you could replace directly L in the call of b with the string). \$\endgroup\$ Commented Nov 24, 2015 at 13:43
  • \$\begingroup\$ @Fatalize cool! As I'm using SWI-Prolog for testing anyway, that sounds like a great idea. \$\endgroup\$ Commented Nov 24, 2015 at 13:49
  • \$\begingroup\$ Also, using b([A,_|T],[H]):-A=H,writef('%s',[T]);b(T,[H]). instead of 2 different rules for b is 7 bytes shorter. Usually, it's always shorter to merge all rules into a single one with ORs ; instead of writing multiple rules, because you avoid repeating the predicate's name and parameters and you avoid a linefeed too ;) \$\endgroup\$ Commented Nov 24, 2015 at 13:51
  • \$\begingroup\$ It's been so long since I learned Prolog that I had totally forgotten that you could OR like that. Great tip! Thanks :) \$\endgroup\$ Commented Nov 24, 2015 at 14:23