LISP 中的字符串
字符串是一组字符。字符串用双引号括起来。
例子:
"hello geek","java","python" etc
示例:显示字符串的 LISP 程序
Lisp
;edisplay hello geek
(write-line "Hello Geek")
;display
(write-line "Welcome to java")
Lisp
; case-sensitive comparison - equal to
(write (string= "Hello Geeks" "Hello Geeks"))
;new line
(terpri)
; case-sensitive comparison - equal to
(write (string= "Hello Geeks" "HelloGeeks"))
;new line
(terpri)
; case-sensitive comparison - not equal to
(write (string/= "Hello Geeks" "Hello Geeks"))
;new line
(terpri)
; case-sensitive comparison - not equal to
(write (string/= "Hello Geeks" "HelloGeeks"))
;new line
(terpri)
; case-sensitive comparison - greater than
(write (string> "Hello Geeks" "Python"))
;new line
(terpri)
; case-sensitive comparison - less than
(write (string< "Hello Geeks" "java"))
;new line
(terpri)
; case-sensitive comparison - greater than or equal to
(write (string>= "Hello Geeks" "Python"))
;new line
(terpri)
; case-sensitive comparison - less than or equal to
(write (string<= "Hello Geeks" "java"))
;new line
(terpri)
Lisp
; case-sensitive comparison - equal to
(write (string-equal "Hello Geeks" "Hello Geeks"))
;new line
(terpri)
; case-sensitive comparison - equal to
(write (string-equal "Hello Geeks" "HelloGeeks"))
;new line
(terpri)
; case-sensitive comparison - not equal to
(write (string-not-equal "Hello Geeks" "Hello Geeks"))
;new line
(terpri)
; case-sensitive comparison - not equal to
(write (string-not-equal "Hello Geeks" "HelloGeeks"))
;new line
(terpri)
; case-sensitive comparison - greater than
(write (string-greaterp "Hello Geeks" "Python"))
;new line
(terpri)
; case-sensitive comparison - less than
(write (string-lessp "Hello Geeks" "java"))
;new line
(terpri)
; case-sensitive comparison - greater than or equal to
(write (string-not-lessp "Hello Geeks" "Python"))
;new line
(terpri)
; case-sensitive comparison - less than or equal to
(write (string-not-greaterp "Hello Geeks" "java"))
;new line
(terpri)
输出:
Hello Geek
Welcome to java
字符串比较函数:
用于比较两个字符串。此外,它们可以分为两类。他们是
区分大小写的函数:
这些函数可以用数学符号表示。Symbol Name Syntax Description = equal to string= This operator checks if the values of the operands are all equal or not, if yes then the condition becomes true(T). otherwise it returns NIL /= not equal to string/= This operator checks if the values of the operands are all different or not, if values are not equal then the condition becomes true(T). otherwise, it returns NIL > greater than string> This operator checks if the values of the operands are monotonically increasing. < less than string< This operator checks if the values of the operands are monotonically decreasing. >= greater than or equal to string>= This operator checks if the value of any left operand is less than or equal to the value of its right operand, if yes then the condition becomes true. <= less than or equal to string<= This operator checks if the value of any left operand is greater than or equal to the value of the next right operand, if yes then the condition becomes true.
示例:演示字符串大小写敏感函数的 LISP 程序
Lisp
; case-sensitive comparison - equal to
(write (string= "Hello Geeks" "Hello Geeks"))
;new line
(terpri)
; case-sensitive comparison - equal to
(write (string= "Hello Geeks" "HelloGeeks"))
;new line
(terpri)
; case-sensitive comparison - not equal to
(write (string/= "Hello Geeks" "Hello Geeks"))
;new line
(terpri)
; case-sensitive comparison - not equal to
(write (string/= "Hello Geeks" "HelloGeeks"))
;new line
(terpri)
; case-sensitive comparison - greater than
(write (string> "Hello Geeks" "Python"))
;new line
(terpri)
; case-sensitive comparison - less than
(write (string< "Hello Geeks" "java"))
;new line
(terpri)
; case-sensitive comparison - greater than or equal to
(write (string>= "Hello Geeks" "Python"))
;new line
(terpri)
; case-sensitive comparison - less than or equal to
(write (string<= "Hello Geeks" "java"))
;new line
(terpri)
输出:
T
NIL
NIL
5
NIL
0
NIL
0
大小写不敏感的函数
这些函数可以用表达式来表示。Name Syntax Description equal string-equal This operator checks if the values of the operands are all equal or not, if yes then the condition becomes true(T). Otherwise, it returns NIL not equal string-not-equal This operator checks if the values of the operands are all different or not, if values are not equal then the condition becomes true(T). Else, it returns NIL greater than string-greaterp This operator checks if the values of the operands are monotonically increasing. less than string-lessp This operator checks if the values of the operands are monotonically decreasing. greater than or equal to string-not-lessp This operator checks if the value of any left operand is less than or equal to the value of its right operand, if yes then the condition becomes true. less than or equal to string-not-greaterp This operator checks if the value of any left operand is greater than or equal to the value of the next right operand, if yes then the condition becomes true.
示例:演示不区分大小写功能的 Lisp 程序
Lisp
; case-sensitive comparison - equal to
(write (string-equal "Hello Geeks" "Hello Geeks"))
;new line
(terpri)
; case-sensitive comparison - equal to
(write (string-equal "Hello Geeks" "HelloGeeks"))
;new line
(terpri)
; case-sensitive comparison - not equal to
(write (string-not-equal "Hello Geeks" "Hello Geeks"))
;new line
(terpri)
; case-sensitive comparison - not equal to
(write (string-not-equal "Hello Geeks" "HelloGeeks"))
;new line
(terpri)
; case-sensitive comparison - greater than
(write (string-greaterp "Hello Geeks" "Python"))
;new line
(terpri)
; case-sensitive comparison - less than
(write (string-lessp "Hello Geeks" "java"))
;new line
(terpri)
; case-sensitive comparison - greater than or equal to
(write (string-not-lessp "Hello Geeks" "Python"))
;new line
(terpri)
; case-sensitive comparison - less than or equal to
(write (string-not-greaterp "Hello Geeks" "java"))
;new line
(terpri)
输出:
T
NIL
NIL
5
NIL
0
NIL
0