Clojure Learning 05: Predicate functions

Source: Internet
Author: User

A predicate function is a judgment, a function that returns a bool value.

clojure (Lisp habit): For functions that Judge functions, there is a function name followed by a "? No. So as long as you see the name of the function with a question mark in the back, you know it must be a judgment function.

1, instance?  checks if the value is of a type

user=> (instance? String "Hello")
true

2, fn?  Determines whether a parameter represents a function

user=> (Def a)
# ' user/a
user=> (fn? a)
False
User=> (fn? filter)
True

3, The predicate for the test number has a

even even?

odd odd?

negative neg?

positive pos?

0 Zero?

Clojure Learning 05: Predicate functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.