prolog-strings

Explain Prolog text representations and conversions for SWI-Prolog.

1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/hafley66/claude-research --skill prolog-strings
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prolog-strings
Source: https://github.com/hafley66/claude-research/tree/main/skills/prolog-strings
Command: npx skills add https://github.com/hafley66/claude-research --skill prolog-strings

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prolog developers often struggle with understanding and converting between the multiple text representations in Prolog (atoms, strings, character lists, and code lists), which can lead to bugs and confusion in text processing tasks.

Core Features & Use Cases

  • Clear explanation of four text representations (atoms, strings, char lists, code lists) and how the global double_quotes flag changes their meaning.
  • Guidance on common predicates and patterns for conversion, testing, and reversible operations (atom_string, string_to_atom, atom_chars, string_length, sub_atom, format) and practical scenarios like parsing and formatting.
  • Use cases include DCG parsing, text processing, and format/2 style output for SWI-Prolog programs.

Quick Start

Explain how to convert between atoms, strings, and code lists in SWI-Prolog and demonstrate atom_string/2 and string_to_atom/2.

Frequently Asked Questions about prolog-strings

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert between atoms, strings, and code lists in SWI-Prolog?

This Skill clarifies the four Prolog text representations: atoms, strings, char lists, and code lists. It explains how the global double_quotes flag changes their meaning to prevent bugs in text processing.

How does the double_quotes flag affect Prolog text representations?

The double_quotes flag changes how SWI-Prolog interprets quoted text, switching between strings, character lists, and code lists. Configuring it correctly ensures your text processing code parses data as intended.

How do I use DCG parsing for text processing in Prolog?

Definite Clause Grammar (DCG) parsing in Prolog requires correctly handling text representations like code lists and atoms. Using reversible predicates ensures your DCG rules can both parse and generate text accurately.

What is the best way to format text output using format/2 in Prolog?

Using format/2 for text output in SWI-Prolog requires understanding how atoms and strings interact with format specifiers. Correct usage ensures properly formatted output without representation mismatch errors.

Why does my Prolog text predicate fail when comparing strings and atoms?

Prolog text predicates fail when comparing strings and atoms because they are distinct types. You must convert them to a common representation using atom_string/2 or string_to_atom/2 before comparison.