You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently is-lowercase-alpha and is-digit compares char individually with each different case. We can replace this with a range check like this:
;; Determines if a character is a digit (0-9).
(define-private (is-digit-test (char (buff 1)))
(and
;; Checks if the character is between '0' and '9' using hex values.
(>= char 0x30) ;; 0
(<= char 0x39) ;; 9
)
)
;; Checks if a character is a lowercase alphabetic character (a-z).
(define-read-only (is-lowercase-alpha-test (char (buff 1)))
(and
;; Checks for each lowercase letter using hex values.
(>= char 0x61) ;; a
(<= char 0x7a) ;; z
)
)
Further, we could use inequality <,> and increase/lower by 1 the ranges and optimize even further but at the risk of reducing clarity.
The text was updated successfully, but these errors were encountered:
Currently
is-lowercase-alpha
andis-digit
compareschar
individually with each different case. We can replace this with a range check like this:Further, we could use inequality
<,>
and increase/lower by 1 the ranges and optimize even further but at the risk of reducing clarity.The text was updated successfully, but these errors were encountered: