Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
(define (palindrome? s)
|
||||
(let ((chars (string->list s)))
|
||||
(equal? chars (reverse chars))))
|
||||
20
Task/Palindrome-detection/Scheme/palindrome-detection-2.ss
Normal file
20
Task/Palindrome-detection/Scheme/palindrome-detection-2.ss
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
(define (palindrome? s)
|
||||
(let loop ((i 0)
|
||||
(j (- (string-length s) 1)))
|
||||
(or (>= i j)
|
||||
(and (char=? (string-ref s i) (string-ref s j))
|
||||
(loop (+ i 1) (- j 1))))))
|
||||
|
||||
;; Or:
|
||||
(define (palindrome? s)
|
||||
(let loop ((s (string->list s))
|
||||
(r (reverse (string->list s))))
|
||||
(or (null? s)
|
||||
(and (char=? (car s) (car r))
|
||||
(loop (cdr s) (cdr r))))))
|
||||
|
||||
> (palindrome? "ingirumimusnocteetconsumimurigni")
|
||||
#t
|
||||
> (palindrome? "This is not a palindrome")
|
||||
#f
|
||||
>
|
||||
Loading…
Add table
Add a link
Reference in a new issue