On Mon, Oct 14, 2019 at 10:57 AM David Bailey <[email protected]> wrote:
>
> On 14/10/2019 17:17, Chris Smith wrote:
>
> It a dictionary. You can look at the results in order with
>
> ans = solve(...)
> for k in ordered(ans):
>    print(k, ans[k])
>
>
> You could also turn that dict into an ordered list with `ans = 
> list(ordered(ans.items()))`.
> On Sunday, October 13, 2019 at 7:54:23 PM UTC-5, Rick Richardson wrote:
>>
>> For example:
>>
>> >>> a,b,e,c,f,d,g,h,i,j,k,l,m,n,o,p = symbols("a b e c f d g h i j k l m n o 
>> >>> p ", integer=True)
>> >>> print 
>> >>> solve([a-(1),a+b-(17),a+e-(20),b+c-(19),b+f-(22),c+d-(21),c+g-(24),d+h-(26),e+f-(25),e+i-(12),f+g-(27),f+j-(14),g+h-(29),g+k-(16),h+l-(18),i+j-(1),i+m-(4),j+k-(3),j+n-(6),k+l-(5),k+o-(8),l+p-(10),m+n-(9),n+o-(11),o+p-(13)],[a,b,e,c,f,d,g,h,i,j,k,l,m,n,o,p])
>>
>> {f: 6, h: 8, k: -5, l: 10, o: 13, c: 3, i: -7, d: 18, g: 21, j: 8, m: 11, n: 
>> -2, a: 1, b: 16, e: 19, p: 0}
>>
>> They come out in random order!
>
> --
>
> Just out of curiosity, will that solution execute ordered(ans) once or every 
> turn of the loop?

The iterator part of a for loop is only executed once.

Aaron Meurer

>
> David
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/ccd193a0-9c50-dd5d-4ffd-fd8a1baaa96e%40dbailey.co.uk.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BFA7%2BgsA2tmHBH8WAA%3Dh7siQuNjbBxC-cBSe61SrW8jw%40mail.gmail.com.

Reply via email to