June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,16 @@
;; Project : Palindrome detection
;; Date : 2018/03/06
;; Author : Gal Zsolt [~ CalmoSoft ~]
;; Email : <calmosoft@gmail.com>
(defun palindrome(x)
(if (string= x (reverse x))
(format t "~d" ": palindrome" (format t x))
(format t "~d" ": not palindrome" (format t x))))
(terpri)
(setq x "radar")
(palindrome x)
(terpri)
(setq x "books")
(palindrome x)
(terpri)

View file

@ -0,0 +1,11 @@
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
function is_palindrome(a)
a = strUpper(a).replace(" ", "")
b = a[-1:0]
return b == a
end
a = "mom"
> is_palindrome(a)

View file

@ -0,0 +1,5 @@
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
b = "mom"
> strUpper(b).replace(" ", "") == strUpper(b[-1:0]) ? "Is a palindrome" : "Is not a palindrome"

View file

@ -24,7 +24,7 @@ variable temp-addr
: reverse-copy ( addr1 addr2 u -- addr1 addr2 )
0 do over I' 1- I - + over I + 1 cmove loop 2drop ;
: palindrome? ( addr1 u1 -- )
: palindrome? ( -- )
get-phrase strip-input position-phrase reverse-copy compare 0= if
." << Valid >> Palindrome."
else ." << Not >> a Palindrome."

View file

@ -0,0 +1,39 @@
MODULE Palindrome;
FROM FormatString IMPORT FormatString;
FROM Terminal IMPORT WriteString,ReadChar;
PROCEDURE IsPalindrome(str : ARRAY OF CHAR) : BOOLEAN;
VAR i,m : INTEGER;
VAR buf : ARRAY[0..63] OF CHAR;
BEGIN
i := 0;
m := HIGH(str) - 1;
WHILE i<m DO
IF str[i] # str[m-i] THEN
RETURN FALSE
END;
INC(i)
END;
RETURN TRUE
END IsPalindrome;
PROCEDURE Print(str : ARRAY OF CHAR);
VAR buf : ARRAY[0..63] OF CHAR;
BEGIN
FormatString("%s: %b\n", buf, str, IsPalindrome(str));
WriteString(buf)
END Print;
BEGIN
Print("");
Print("z");
Print("aha");
Print("sees");
Print("oofoe");
Print("deified");
Print("Deified");
Print("amanaplanacanalpanama");
Print("ingirumimusnocteetconsumimurigni");
ReadChar
END Palindrome.

View file

@ -1,14 +1,14 @@
let rem_space str =
let len = String.length str in
let res = String.create len in
let res = Bytes.create len in
let rec aux i j =
if i >= len
then (String.sub res 0 j)
then (Bytes.sub_string res 0 j)
else match str.[i] with
| ' ' | '\n' | '\t' | '\r' ->
| ' ' | '\n' | '\t' | '\r' ->
aux (i+1) (j)
| _ ->
res.[j] <- str.[i];
| _ ->
Bytes.set res j str.[i];
aux (i+1) (j+1)
in
aux 0 0

View file

@ -0,0 +1,21 @@
void setup(){
println(isPalindrome(InsertPalindromeHere));
}
boolean isPalindrome(string check){
char[] letters = new char[check.length];
string invert = " ";
string modCheck = " " + check;
for(int i = 0; i < letters.length; i++){
letters[i] = check.charAt(i);
}
for(int i = letters.length-1; i >= 0; i--){
invert = invert + letters[i];
}
if(invert == modCheck){
return true;
} else {
return false;
}
}

View file

@ -1,6 +1,6 @@
fn is_palindrome(string: &str) -> bool {
let half_len = string.len()/2;
string.chars().take(half_len).eq(string.chars().take(half_len).rev())
string.chars().take(half_len).eq(string.chars().rev().take(half_len))
}
macro_rules! test {

View file

@ -0,0 +1,5 @@
if [[ "${text}" == "$(rev <<< "${text}")" ]]; then
echo "Palindrome"
else
echo "Not a palindrome"
fi