How to resolve the algorithm Palindrome detection step by step in the Bracmat programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Palindrome detection step by step in the Bracmat programming language

Table of Contents

Problem Statement

A palindrome is a phrase which reads the same backward and forward. Write a function or program that checks whether a given sequence of characters (or, if you prefer, bytes) is a palindrome. For extra credit:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Palindrome detection step by step in the Bracmat programming language

Source code in the bracmat programming language

( ( palindrome
  =   a
    .     @(!arg:(%?a&utf$!a) ?arg !a)
        & palindrome$!arg
      | utf$!arg
  )
& ( desep
  =   x
    .     @(!arg:?x (" "|"-"|",") ?arg)
        & !x desep$!arg
      | !arg
  )
&     "In girum imus nocte et consumimur igni"
      "Я иду с мечем, судия"
      "The quick brown fox"
      "tregða, gón, reiði - er nóg að gert"
      "人人為我,我為人人"
      "가련하시다 사장집 아들딸들아 집장사 다시 하련가"
  : ?candidates
&   whl
  ' ( !candidates:%?candidate ?candidates
    &   out
      $ ( !candidate
          is
          (   palindrome$(low$(str$(desep$!candidate)))
            & indeed
          | not
          )
          a
          palindrome
        )
    )
&
);

  

You may also check:How to resolve the algorithm Draw a clock step by step in the AWK programming language
You may also check:How to resolve the algorithm Set consolidation step by step in the D programming language
You may also check:How to resolve the algorithm Jacobsthal numbers step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Loops/N plus one half step by step in the SNUSP programming language
You may also check:How to resolve the algorithm Feigenbaum constant calculation step by step in the XPL0 programming language