Skip to content

Commit

Permalink
kickOut and bringIn a reason
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Sep 4, 2024
1 parent 2ae55a1 commit 21e42f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

> - https://github.com/cicada-lang/propagator/issues/3
barometer-belief-system.test.ts -- test `beliefSystemQuery`

barometer-belief-system.test.ts -- 理解我们的测试中与书中有差异的地方

- 书中第一个测试只有:
Expand Down
14 changes: 11 additions & 3 deletions src/belief-system/isBeliefBelieved.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Belief } from "../belief/index.js"
import type { Reasons } from "../reason/index.js"
import { type Reason, type Reasons } from "../reason/index.js"

export function isBeliefBelieved<A>(belief: Belief<A>): boolean {
return Array.from(belief.reasons).every(isReasonBelieved)
}

export const globelReasonBlackList: Reasons = new Set()

function isReasonBelieved(entry: string): boolean {
return !globelReasonBlackList.has(entry)
function isReasonBelieved(reason: Reason): boolean {
return !globelReasonBlackList.has(reason)
}

export function kickOut(reason: Reason): void {
globelReasonBlackList.add(reason)
}

export function bringIn(reason: Reason): void {
globelReasonBlackList.delete(reason)
}

0 comments on commit 21e42f0

Please sign in to comment.