Julia is not rendering text correctly in the REPL

Currently, I am running very simple loops using a custom function that generate an array. I am then taking the last value of the array and pushing it into another. Fortunately the function returns the right values but all the print statements are broken… only returning blank lines until the final result.

Furthermore, the welcome screen doesn’t seem to render either.

So, for example, I am running a calculation and then asking it to print using a print() statement - what I get is 100 blank lines and then the last result. Any thoughts?

function marty(Wager, GamesPlayed; GameWinProb = 0.5, CashInHand = Wager)
    CurrentWager = Wager
    Balance = CashInHand
    BalResults = []
        for i = 1:GamesPlayed
            win_loose_sim = rand(Bernoulli(GameWinProb))

            if win_loose_sim == true
                    Balance = Balance + CurrentWager
                    CurrentWager = Wager
                elseif win_loose_sim == false
                    Balance = Balance - CurrentWager
                    CurrentWager = Wager * 2
            push!(BalResults, Balance)

#println("Gain/Loss after $GamesPlayed games: ", Balance - CashInHand,'$')
return BalResults

Here is the offending function

function x_hand_dist(trials, games)
finalresult = []

for i = 1:trials
    trial_result = last(marty(5, games, GameWinProb = 0.185, CashInHand = 400))
    push!(finalresult, trial_result)


return finalresult

Same Issue but worse…

function resim()
trials = 1000
    for games = 10:5:1000
        sim = mean(x_hand_dist(trials, games))
        #print("Total Games:", games,"    ","Mean Balance:", sim)

       if  sim < 0
                println("Total Games:", games,"    ","Mean Balance:", mean(x_hand_dist(trials, games)))
            println("Total Games:", games,"    ","Mean Balance:", sim)

Are you using some weird color scheme in your REPL? What terminal are you using?

I am using the latest Atom… with Atom One theme

I just revised the code to reproduce the error… sorry for the cut and copy mistake lol

The code is definitely not what’s causing the error. it’s the color scheme. I would recommend trying a different color scheme.

Nah, pretty sure this is just a known Juno bug where printing at the start of the session sometimes doesn’t work.

1 Like

My first thought but actually the problem is reproducible in VSCode, the straight REPL terminal and on a Jupyter Workbook on a different machine. I reproduced the issue in 1.61, 1.6.5 and 1.7.1

Yes, I’ve seen similar things off an on in the windows terminal with the normal dark mode. Text is intermittently colored black instead of white. Select it, and it turns white.

Remove println() line in your marty function and all will be OK I think.

After removing it I get:

julia> resim()
Total Games:10    Mean Balance:346.12
Total Games:15    Mean Balance:315.99
Total Games:20    Mean Balance:288.535
Total Games:25    Mean Balance:260.39
Total Games:30    Mean Balance:229.455
Total Games:35    Mean Balance:200.685
Total Games:40    Mean Balance:174.51
Total Games:45    Mean Balance:146.775
Total Games:50    Mean Balance:116.83
Total Games:55    Mean Balance:87.255
Total Games:60    Mean Balance:57.7
Total Games:65    Mean Balance:32.285
Total Games:70    Mean Balance:0.92
Total Games:75    Mean Balance:-28.545

Bogumil, you rock! I would have never guessed that that println() would cascade like that in my other functions. A true discovery.