# Running from different version of Julia

**URL:** <https://discourse.julialang.org/t/running-from-different-version-of-julia/105298>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [October 23, 2023, 2:51am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298 "2023-10-23T02:51:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allan\_Olave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_olave/32/38653_2.png) [@Allan\_Olave](https://discourse.julialang.org/u/Allan_Olave)\
**Post date:** [October 23, 2023, 2:51am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/1 "2023-10-23T02:51:39Z")

</div>

With the following code

```julia
function finding_minimum_sum(list_of_distance, list_of_projected_load, show_list = true)
	x = list_of_distance
	y = list_of_projected_load
	l1 = length(x)
	l2 = length(y)
	xy = []
	for i in 1:l2
		xy1a = []
		xy2a = []
		for j in 1:l1
			if (i ≤ j) && (i != l2)
				push!(xy1a, sum(x[i:j])*y[j+1])
			end
			if (i != 1 && i > j)
				push!(xy2a, sum(x[j:(i-1)])*y[j])
			end
		end
		if !isempty(xy1a) && !isempty(xy2a)
			an = collect(Iterators.flatten([xy2a, xy1a]))
			push!(xy, sum(insert!(an, i, y[i])))
		else
			if i == 1
				push!(xy, sum(collect(Iterators.flatten([y[1], xy1a]))))
			else
				push!(xy, sum(collect(Iterators.flatten([xy2a, y[l2]]))))
			end
		end
	end
	min_sum = extrema(xy)[1]
	ls = findall(x->x==min_sum, xy)
	if show_list
		return xy, ls
	else
		return ls
	end
end

```

given with the following:  
lst1 = [2, 4]  
lst2 = [1, 2, 3]  
finding\_minimum\_sum(lst1, lst2)

if the above code run in Julia 1.9.2 the output will be:  
([23, 16, 17], [2]

while running the code in Julia 1.9.3 the output will be:  
([23], [1])

How to resolve to the new version?

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [October 23, 2023, 7:17am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/2 "2023-10-23T07:17:49Z")

</div>

Are you sure you ran the same code in both?  
I just tried it on 1.8.5 and 1.9.3 and got the same in both cases `(Any[23, 16, 17], [2])`.

---

<div class="post-metadata">

**Author:** ![Allan\_Olave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_olave/32/38653_2.png) [@Allan\_Olave](https://discourse.julialang.org/u/Allan_Olave)\
**Post date:** [October 23, 2023, 7:52am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/3 "2023-10-23T07:52:45Z")

</div>

Yes, I’m sure and here’s my proof. (I take a screen shots, these are from different laptop) see my upload photos.)

 ![Julia1-9-2 function find Max Sum](https://global.discourse-cdn.com/julialang/original/3X/0/5/05278fe3c7e4597b79bce5c7690f7fc51a5718c1.png)  
 ![Julia1-9-3_Function_Find_Max_Sum](https://global.discourse-cdn.com/julialang/original/3X/6/3/63629827bcbae6fe50482497476ba77f7166cd20.png)

Is it possible that the problem is in installation of Julia 1.9.3 (I use portable apps)?

Thank you for giving your time…

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [October 23, 2023, 8:05am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/4 "2023-10-23T08:05:39Z")

</div>

Yeah, I couldn’t spot any difference from the screenshots. Just to double check (I’m not trying to be annoying 😅 ), can you also show the values of `list_of_distance` and `list_of_projected_load` in both notebooks, right before you call the function?

Here’s some other things that might cause the issue, if both the function code and the input variables are exactly identical:

- There might be other code that, e.g., redefines some functions or sets some global variables which interfere with the code. It’s impossible to know that without seeing the both notebooks.
- If the code is running on different machines there might be something different in both `startup.jl` files.
- … black magic?

If you start a new REPL and just paste this code in it, do you still get different results? (that’s what I tried)

```julia
function finding_minimum_sum(list_of_distance, list_of_projected_load, show_list = true)
	x = list_of_distance
	y = list_of_projected_load
	l1 = length(x)
	l2 = length(y)
	xy = []
	for i in 1:l2
		xy1a = []
		xy2a = []
		for j in 1:l1
			if (i ≤ j) && (i != l2)
				push!(xy1a, sum(x[i:j])*y[j+1])
			end
			if (i != 1 && i > j)
				push!(xy2a, sum(x[j:(i-1)])*y[j])
			end
		end
		if !isempty(xy1a) && !isempty(xy2a)
			an = collect(Iterators.flatten([xy2a, xy1a]))
			push!(xy, sum(insert!(an, i, y[i])))
		else
			if i == 1
				push!(xy, sum(collect(Iterators.flatten([y[1], xy1a]))))
			else
				push!(xy, sum(collect(Iterators.flatten([xy2a, y[l2]]))))
			end
		end
	end
	min_sum = extrema(xy)[1]
	ls = findall(x->x==min_sum, xy)
	if show_list
		return xy, ls
	else
		return ls
	end
end

lst1 = [2, 4]
lst2 = [1, 2, 3]
finding_minimum_sum(lst1, lst2)

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 23, 2023, 8:41am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/5 "2023-10-23T08:41:03Z")

</div>

Just to corroborate what Sevi is saying, here’s what I get on 1.9.2 and 1.9.3:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/3/c3255a798eef87c4391ca6e7ac90bea356e4bc0a.png)

Also your code is just a series of fairly basic functions shipped with the base Julia install, so it’s exceedingly unlikely that there’s such a change in the output returned between Julia patch versions (indeed this would likely be a serious bug in the language).

---

<div class="post-metadata">

**Author:** ![Allan\_Olave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_olave/32/38653_2.png) [@Allan\_Olave](https://discourse.julialang.org/u/Allan_Olave)\
**Post date:** [October 23, 2023, 8:46am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/6 "2023-10-23T08:46:56Z")

</div>

Thank you again…  
Here I take a screen shot of the code with variables, and also I did delete all the variables and function other than the code you see in the pictures.

 ![Julia 1-9-3 function find max](https://global.discourse-cdn.com/julialang/original/3X/e/3/e3f5821e8fd2b56d96aec7566a49f32b9aead4f6.png)

I also tried in Julia REPL

 ![Julia 1-9-3 function find max REPL](https://global.discourse-cdn.com/julialang/original/3X/d/a/dafce7ae8a84853fb42c271ec0ab1e718aff2b8f.png)

I suspected that in portable of Julia 1.9.3 might got the problem, I remember that when add packages it always not finished( It hangs - I don’t know what exact terms), so what i did is to close the Julia REPL when it happens, then I will open it again then add package then it hangs again… many times i did that… but when I check the status it shows that the package is installed. so i continue adding packages even though it always hangs.

I used portable julia(not julia installer) because our company restricted in installation of software…

Thank you.

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [October 23, 2023, 8:48am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/7 "2023-10-23T08:48:53Z")

</div>

IT’s time to talk about Function programming

In Functional programming, there are two types of Functions

1. Pure Function like sin()
2. Impure Function like time()

A Pure Function will ALWAYS return the same output for the same input. For example

sin(pi/6) == 0.5

An Impure Function MAY give different output for the same input like

julia\> time()

1.698050756408463e9

julia\> time()

1.698050757773564e9

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 23, 2023, 8:50am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/8 "2023-10-23T08:50:59Z")

</div>

Could you explain what a “portable Julia” is?

Also to narrow down the possible sources of the issue it would be good to forget about Pluto and even opening REPLs for a moment. Can you just create a file `test.jl` your `find_maximum_sum` function in and then at the bottom add

```julia
println(find_maximum_sum([2,4], [1,2,3]))

```

Then call Julia from the terminal without startup file and run this file, which will now print the result to the terminal:

```julia
C:\Users\...>C:/.../Julia-1.9.3/bin/julia.exe --startup-file=no findminsum.jl
(Any[23, 16, 17], [2])

C:\Users\...>C:/.../Julia-1.9.2/bin/julia.exe --startup-file=no findminsum.jl
(Any[23, 16, 17], [2])

```

---

<div class="post-metadata">

**Author:** ![Allan\_Olave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_olave/32/38653_2.png) [@Allan\_Olave](https://discourse.julialang.org/u/Allan_Olave)\
**Post date:** [October 23, 2023, 8:58am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/9 "2023-10-23T08:58:14Z")

</div>

This is what I mean of Julia Portable, see picture below.

 ![JuliaScreenShots](https://global.discourse-cdn.com/julialang/original/3X/7/b/7b572e68218038288e3e46d5d17fc265bb1f224c.png)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 23, 2023, 9:02am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/10 "2023-10-23T09:02:47Z")

</div>

That gives me the same result:

```julia
C:\(...)>C:/(...)/julia-1.9.3-win64/julia-1.9.3/bin/julia.exe --startup-file=no findminsum.jl
(Any[23, 16, 17], [2])

```

so it’s not a problem with the portable version.

---

<div class="post-metadata">

**Author:** ![Allan\_Olave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_olave/32/38653_2.png) [@Allan\_Olave](https://discourse.julialang.org/u/Allan_Olave)\
**Post date:** [October 23, 2023, 9:08am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/11 "2023-10-23T09:08:24Z")

</div>

so… I still don’t know what is the reason why my julia 1.9.3 gives different output…  
Thank you, anyway…

---

<div class="post-metadata">

**Author:** ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)\
**Post date:** [October 23, 2023, 9:11am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/12 "2023-10-23T09:11:50Z")

</div>

I would add a few @show into the code and look where the two executions start to diverge and then try to pin down what the problem might be. Since the code is short and test data is small, that should be quite simple to do.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [October 23, 2023, 1:08pm UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/13 "2023-10-23T13:08:33Z")

</div>

Your code in your Julia 1.9.3 is different than your Julia 1.9.2 notebook.

The code you pasted above and are using for Julia 1.9.2 is as follows.

```julia
function finding_minimum_sum(list_of_distance, list_of_projected_load, show_list = true)
    # ...
    for i in 1:l2
        # ...
    end
    if show_list
        return xy, ls
    else
        return ls
    end
end

```

The code you have in your Julia 1.9.3 notebook is as follows with the `if` statement inside the for loop.

```julia
function finding_minimum_sum(list_of_distance, list_of_projected_load, show_list = true)
    # ...
    for i in 1:l2
        # ...
        if show_list
            return xy, ls
        else
            return ls
        end
    end
end

```

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [October 23, 2023, 3:12pm UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/14 "2023-10-23T15:12:34Z")

</div>

Great Scott!

Talk about not seeing the forest for all the trees… I thought I looked at it very carefully, but didn’t catch the block scopes. Can’t unsee it now 🤣

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [October 23, 2023, 3:18pm UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/15 "2023-10-23T15:18:53Z")

</div>

It’s a bit disturbing how bad “human vision” is. I’m finding it questionable that “we” are the ones “training” AI how to do “computer vision”.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [October 23, 2023, 3:19pm UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/16 "2023-10-23T15:19:57Z")

</div>

> [@Allan\_Olave](#):
>
> ```julia
> xy1a = []
> xy2a = []
> 
> ```

While we are here, I should point out that you probably want to add a type to these arrays, especially if the the element type can be made concrete.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [October 24, 2023, 12:13am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/17 "2023-10-24T00:13:05Z")

</div>

> [@Sevi](#):
>
> I thought I looked at it very carefully

Best bet in these situations is to copy/paste into different files and then `diff file1.jl file2.jl`

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [October 24, 2023, 12:19am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/18 "2023-10-24T00:19:10Z")

</div>

To be fair, the OP only gave us the text for one version. The rest were screenshots.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [October 24, 2023, 12:37am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/19 "2023-10-24T00:37:23Z")

</div>

Oh yeah, I thought the person I was replying to was op - my bad.

---

<div class="post-metadata">

**Author:** ![Allan\_Olave](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_olave/32/38653_2.png) [@Allan\_Olave](https://discourse.julialang.org/u/Allan_Olave)\
**Post date:** [October 24, 2023, 12:40am UTC](https://discourse.julialang.org/t/running-from-different-version-of-julia/105298/20 "2023-10-24T00:40:27Z")

</div>

Thank you, I notice now. 😅
