Boolean combinators
In the Clojure Tip above, I described a kind of Boolean combinator that lets us build complex rules out of simpler rules. Your task is to build those combinators. Please define:
(defn rule-and
([])
([rule])| (ns ants.core) | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; Copyright (c) 2008 Rich Hickey. All rights reserved. | |
| ; The use and distribution terms for this software are covered by the | |
| ; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
| ; which can be found in the file CPL.TXT at the root of this distribution. | |
| ; By using this software in any fashion, you are agreeing to be bound by | |
| ; the terms of this license. | |
| ; You must not remove this notice, or any other, from this software. |
Boolean combinators
In the Clojure Tip above, I described a kind of Boolean combinator that lets us build complex rules out of simpler rules. Your task is to build those combinators. Please define:
(defn rule-and
([])
([rule])| ;; source code related to the project shown in this video: | |
| ;; https://youtu.be/_XiEc0g2wL8 | |
| ;; author: adam-james | |
| (ns hc.main) | |
| (defn hiccup? | |
| [item] | |
| (and (vector? item) | |
| (keyword? (first item)))) |
| (ns graph) | |
| (def graph | |
| {:A {:children #{:E :B} | |
| :population 200 | |
| :id :A} | |
| :B {:children #{:A :C :E} | |
| :population 300 | |
| :id :B} | |
| :C {:children #{:B :D} |
| /*** MIT LICENSE | |
| Copyright (c) 2022 torcado | |
| Permission is hereby granted, free of charge, to any person | |
| obtaining a copy of this software and associated documentation | |
| files (the "Software"), to deal in the Software without | |
| restriction, including without limitation the rights to use, | |
| copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the | |
| Software is furnished to do so, subject to the following |