1. Home
  2. /
  3. Prolog
  4. /
  5. Theme Toggle Only

Theme Toggle Only - Prolog Typing CST Test

Loading…

Theme Toggle Only — Prolog Code

Toggles theme multiple times.

:- dynamic(isDark/1).
isDark(false).
toggle_theme :- isDark(D), D1 is (D = false -> true ; false), retract(isDark(D)), assert(isDark(D1)).

% Example
?- write('Initial Theme: '), isDark(D), write(D), nl, toggle_theme, isDark(D1), write('Toggled Theme: '), write(D1), nl.

Prolog Language Guide

Prolog (Programming in Logic) is a high-level, declarative programming language focused on logic programming and symbolic reasoning. It is widely used in artificial intelligence, natural language processing, and rule-based systems, enabling developers to express knowledge and relationships rather than step-by-step instructions.

Primary Use Cases

  • ▸Expert systems and rule-based AI
  • ▸Natural language processing
  • ▸Automated theorem proving
  • ▸Knowledge representation and reasoning
  • ▸Constraint logic programming

Notable Features

  • ▸Declarative syntax: describe what to solve, not how
  • ▸Built-in backtracking search
  • ▸Unification for pattern matching
  • ▸Logical inference engine
  • ▸Support for recursion and symbolic computation

Origin & Creator

Developed in 1972 by Alain Colmerauer and Robert Kowalski at the University of Marseille.

Industrial Note

Prolog underpins many AI applications, including expert systems, natural language understanding, and theorem proving frameworks.

More Prolog Typing Exercises

Prolog Counter SimulationProlog Simple AdditionProlog FactorialProlog Fibonacci SequenceProlog Max of Two NumbersProlog List SumProlog Even Numbers FilterProlog Conditional Counter IncrementProlog Resettable Counter

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher