Game Maker Games, Articles, Tutorials & More

Game Maker Network


Howdy, Guest! Please sign in or register an account.

Print

is_palindromic

By Daniel · December 24, 2008

Tests whether the given string is palindromic

// is_palindromic(str, case_sensitive)
// Tests whether the given string is palindromic

var pLen, hLen, i;

if (!argument1)
  argument0 = string_lower(argument0);

pLen = string_length(argument0) + 1;
hLen = pLen / 2;

for (i = 1; i < hLen; i += 1)
  if (string_char_at(argument0, i) != string_char_at(argument0, pLen - i))
    return false;

return true;

Categories: String handling

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement