We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d787f49 commit 3d7cb49Copy full SHA for 3d7cb49
dana/programs/palindrome.dana
@@ -0,0 +1,35 @@
1
+def main
2
+
3
+ def check_pal is byte: s as byte[]
4
5
+ var res is byte
6
+ var i l is int
7
8
+ l:=strlen(s)
9
+ i:=0
10
+ res:=true
11
12
+ loop:
13
+ if i = l/2: break
14
+ elif not s[i] = s[l-i-1]:
15
+ res:=false
16
+ break
17
+ else:
18
+ i:=i+1
19
20
+ return: res
21
22
23
+ val is_pal is byte
24
+ val input is byte []
25
26
+ writeString: "Give a string with maximum length 30: "
27
+ readString: 30, input
28
+ writeString: input
29
30
+ is_pal := check_pal: input
31
32
+ if is_pal:
33
+ writeString: " ... is palindrome\n"
34
35
+ writeString: " ... is not palindrome\n"
0 commit comments