Stream: helpdesk (published)

Topic: ✔ showing expression with variables substituted and result


view this post on Zulip Peter Goodall (Nov 27 2021 at 01:10):

@Andrey Oskin If I'd known enough - I would have followed your suggestion :-)

I spent quite some time learning about macros, MacroTools.jl and Match.jl. I also enjoyed watching "JuliaCon 2020 | Advanced Metaprogramming Tools | Mike Innes".

The result is that I much better understand what I'm asking for, and what the tools do. Maybe Cassette would do what I want. I wrote something pretty simple - which does the job ( abbreviated):

function run_identity(str)
    evp = eval  Meta.parse
    evp("@show " * str)
end

# pvo=permutationsWithOrder(source-set, tuple-size)

# Associativity by exhaustion - feasible because 𝔹 is a small type.
pr("Associativity")
let
    comb = pwo(bools, 3)
    for (a, b, c) in comb
        run_identity("($a$b) ⊻ $c == $a ⊻ ($b$c)")
    end
end

[...]

Associativity
(one  zero)  zero == one  (zero  zero) = true
(zero  one)  one == zero  (one  one) = true
(one  zero)  one == one  (zero  one) = true
(zero  zero)  one == zero  (zero  one) = true
(one  one)  one == one  (one  one) = true
(zero  zero)  zero == zero  (zero  zero) = true
(zero  one)  zero == zero  (one  zero) = true
(one  one)  zero == one  (one  zero) = true

Commutativity
zero  one == one  zero = true
one  zero == zero  one = true
one  one == one  one = true
zero  zero == zero  zero = true

Self-inverting
zero  zero == 𝕫 = true
one  one == 𝕫 = true

view this post on Zulip Notification Bot (Nov 27 2021 at 01:14):

Peter Goodall has marked this topic as resolved.


Last updated: Oct 02 2023 at 04:34 UTC