版博士V2.0程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

BooleanAlgebra.js 2.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { getBooleanAlgebra } from './function';
  2. // -------------------------------------------------------------------------------------
  3. // combinators
  4. // -------------------------------------------------------------------------------------
  5. /**
  6. * Every boolean algebras has a dual algebra, which involves reversing one/zero as well as join/meet.
  7. *
  8. * @since 2.10.0
  9. */
  10. export var reverse = function (B) { return ({
  11. meet: function (x, y) { return B.join(x, y); },
  12. join: function (x, y) { return B.meet(x, y); },
  13. zero: B.one,
  14. one: B.zero,
  15. implies: function (x, y) { return B.join(B.not(x), y); },
  16. not: B.not
  17. }); };
  18. // -------------------------------------------------------------------------------------
  19. // instances
  20. // -------------------------------------------------------------------------------------
  21. /**
  22. * @category instances
  23. * @since 2.0.0
  24. */
  25. export var booleanAlgebraVoid = {
  26. meet: function () { return undefined; },
  27. join: function () { return undefined; },
  28. zero: undefined,
  29. one: undefined,
  30. implies: function () { return undefined; },
  31. not: function () { return undefined; }
  32. };
  33. // -------------------------------------------------------------------------------------
  34. // deprecated
  35. // -------------------------------------------------------------------------------------
  36. /**
  37. * Use [`reverse`](#reverse) instead.
  38. *
  39. * @category zone of death
  40. * @since 2.0.0
  41. * @deprecated
  42. */
  43. export var getDualBooleanAlgebra = reverse;
  44. /**
  45. * Use [`BooleanAlgebra`](./boolean.ts.html#booleanalgebra) instead.
  46. *
  47. * @category zone of death
  48. * @since 2.0.0
  49. * @deprecated
  50. */
  51. export var booleanAlgebraBoolean = {
  52. meet: function (x, y) { return x && y; },
  53. join: function (x, y) { return x || y; },
  54. zero: false,
  55. one: true,
  56. implies: function (x, y) { return !x || y; },
  57. not: function (x) { return !x; }
  58. };
  59. /**
  60. * Use [`getBooleanAlgebra`](./function.ts.html#getbooleanalgebra) instead.
  61. *
  62. * @category zone of death
  63. * @since 2.0.0
  64. * @deprecated
  65. */
  66. export var getFunctionBooleanAlgebra = getBooleanAlgebra;