# main.jl
# Code to generate various practice flashcards
# for Julia's || and && operators.


# Change this if you want to generate more or fewer flashcards. There are 127 possibilities in total.
NUM_FLASHCARDS = 30

#----------------------------------------------------------#

operators = (:(||), :(&&))
bools = (true, false)

# It's good practice to preallocate the arrays.

A = Array{Bool}(undef, NUM_FLASHCARDS, 4)
B = Array{Symbol}(undef, NUM_FLASHCARDS, 3)

# Now we fill them with randomly-selected members from the
# tuples above.

Random.rand!(A, bools)
Random.rand!(B, operators)

# Finally, let's make the flashcards themselves. S will have
# the question slide, and E will have the answer slide.

S = Array{String}(undef, NUM_FLASHCARDS)
E = Array{Bool}(undef, NUM_FLASHCARDS)

for i in 1:size(S)[1]
    S[i] = "$(A[i,1]) $(B[i,1]) $(A[i,2]) $(B[i,2]) $(A[i,3]) $(B[i,3]) $(A[i,4])"
end

@. E = eval(Meta.parse(S))

#----------------------------------------------------------#


open("..\\Julia-Short-Circuit-Flashcard-Generators\\generated_flashcards.txt", "w") do io
    for i in 1:size(S)[1]
        print(io, "$(S[i])\n$(E[i])\n\n")
    end
end

println("Flashcards generated.~")
# Good work, my friends.



#----------------------------------------------------------#
