« first day (2575 days earlier)      last day (1906 days later) » 

7:49 AM
Why doesn't Conjugate ignore Surd? This returns unchanged:
Conjugate[Surd[x, 2]] // Simplify
 
 
5 hours later…
1:17 PM
@Glorfindel I've observed that you fixed quite a lot of broken image links, recently. Thanks for that! It is a shame that your edits still have to be approved...
 
Anyone familiar with some deep python magic?
Can you explain me how this thing with yield can be rewritten in Mathematica?
Example:
`def f(labels):
if len(labels) == 1:
yield labels[0]
else:
for i in range(1, len(labels)):
for left in f(labels[:i]):
for right in f(labels[i:]):
yield [left, right]

for i in f([1,2,3,4,5]):
print(i)`
 
1:42 PM
I don't know python but:
list = {a, b, c, d, e};
{list[[;; #]], list[[# ;;]]} & /@ Range@Length@list
@IstvánZachar like that? I am not sure what is the expected result :)
 
@Kuba Thanks Kuba, but this doesn't seem to result in the same list.
Never mind, I figured out a way to Mathematica-fying the python code, using this help
 
which list? ;)
 
1744
A: What does the "yield" keyword do?

user28409Shortcut to Grokking yield When you see a function with yield statements, apply this easy trick to understand what will happen: Insert a line result = [] at the start of the function. Replace each yield expr with result.append(expr). Insert a line return result at the bottom of the function. Y...

@Kuba Well, your result is not the one I expected.
or the one the python code returns
BTW, how do you do multiline code in chat?
 
paste -> select all -> Ctrl+k
 
ClearAll[enum];
enum[labels_List] := Module[{n = Length@labels, res = {}},
   If[Length@labels == 1, AppendTo[res, labels[[1]]],
    Do[AppendTo[res, {left, right}],
     {i, 2, n},
     {left, enum@Take[labels, {1, i - 1}]},
     {right, enum@Take[labels, {i, n}]}]];
   res];
enum@{"A", "B", "C", "D", "E"}
@Kuba Thanks!
 
1:55 PM
@IstvánZachar feels similar to Sow but I will stop here ;)
 
@Kuba Yeah, I wrote the Sow-ed version too, but since this is a recursive algo, it is ultimately a dead-end for me.
Bugger.
 
 
3 hours later…
5:56 PM
@IstvánZachar yield is used with an object with internal state so you'd have to get OOP into Mathematica or use the GeneralUtilities`Iterator object that existed at one point
Or you could create a Function inside a Module that uses the Module state.
 
@Kuba - not to offend, but when you put a semicolon at the beginning of the line it is literally the ugliest thing I've ever laid eyes on
5
 
6:17 PM
I hope the lightheartedness of that comment comes through in a chatroom setting, but I think I would have a hard time reading more code in that format
 
@JasonB. I borrowed it from @WReach. I think you are underestimating it ;)
 
I'm looking at my local copy of DevTools and I think I might need to run it through the general utilities PrettyForm first :-)
 
Take a look at:
If[
  condition
, something
; somethingelse
, else
; else
]
vs
If[
  condition,
  something;
  somethingelse,
  else;
  else
]
 
If[
okay, how to multi-line comment here?
 
Pase code + Ctrl+K
For a code block
 
6:24 PM
@JasonB. Paste all code into one message and Ctrl+K
 
If[
    condition
    ,
    something;
    ,
    else
]
 
No indentation? Savage.
 
the indentation didn't make it through this comment system - that would be savage for sure
 
:)
 
If[
	condition
	,
	something;
	,
	else
]
oh my god chat room makes it look awful, but anyway, I do see the appeal of putting the comma on it's own line for If statements
but at the beginning of a line is a bridge too far
 
6:26 PM
Ok, don't know what to say :) I think it is a matter of preference.
 
I do have idiosyncrasies that prevent me from doing some things though - I can't read python because it's lack of brackets
 
Or are there objective arguments against my style?
 
@Kuba I understand all the advantages of putting commas and semicolons first and I read through WReachs argumentation for it. I entirely understand how practical it is, but I also find it ugly.
 
I didn't spend to much time with other languages so maybe that is the reason I don't
Also, I started using it not because I find it very pretty but because it works for me ;) Till then I was always annoyed by something in my code. Now only by bugs
I find it very readable despite only two spaces of indentation.
 
6:48 PM
@JasonB. yeah, can't remember every reason I like it but having compact yet readable code is one of most important ones.
 
6:59 PM
It wasn't really fair of me to call you out like that, you don't need to defend writing the code how you like it
 
Concerning Kuba's style of coding, I have tried it and it seems to be a big improvement for me. I'm not sure why, maybe because the structure of the tree of code appears at first glance.
Maybe it's because my master eye is the links one (?)
 
Generally speaking as long as the same convention is used throughout a code base that's all that matters. So I know intellectually that there is nothing wrong with beginning a line with a semicolon, I just couldn't stop myself from saying something. Will keep mum on the subject now
 
@JasonB. You waited longer than I'd have thought about your ability to hold yourself :)
@andre314 I had the same impression. Just it feels better to write code this way.
 
7:17 PM
Analyzing Data from the Cuba Meteorite Fall of Feb 1, 2019
https://community.wolfram.com/groups/-/m/t/1605478
 
7:45 PM
@andre314 since you are using it you will find this not interesting, @JasonB. you too but in a different sense :)

So, that format has a downside when it comes to commenting the first statement after variable specification. E.g.:

Module[{}
, something
; somethingElse
; anotherOne
]

Now, if you comment `something` you will need to add a coma. You can comment across two lines but that is ugly, here is what I do with `Modules` now:
Module[{}, Null
; something
; somethingElse
; anotherOne
]
 
8:28 PM
my eyes are burning
i have never seen this comma/semicolon at the beginning of a line thing, and i wish i never had
for a small condition this is the prettiest, IMO:
 
It is absolutely great, useful and helpful. Instead of , Null one can also just use ,""
 
If[condition,
    foo
    ,
    bar
]
Wow the formatting in chat is rather difficult
 
@GenericAccountName I should have known this conversation would draw you in ;-)
 
The problem in nontrivial code is that there are a lot of lines, and I at least am commenting and copying a lot of stuff around. Only since I adapted Kubas styling it feels quicker to read and scan and maintain.
 
I tried so hard not to
 
8:34 PM
So is the primary utility of this indenting style that it is easier to comment out portions?
 
Yes, and readability ( of thousands of lines ... )
 
@JasonB. of course it is not the main advantage :) p.s. deleting applies as well
But the Null example was partially a joke :)
I did it once or twice but come on ;)
@GenericAccountName have I met you?
 
@Kuba I've seen your name on here plenty.. not sure we've spoken directly
 
@GenericAccountName I am asking because only today I realized you are one of THEM :) And I've been to WTC before.
 
I've tried the semi-colon first thing and it makes me physically ill every time I do it
I've never really had much of an issue with semi-colons though...
 
8:43 PM
:) I have attended the past 3 WTC
 
I work the same way I would in python which is to basically only focus on the whitespace and so that's what my brain focuses on.
 
@GenericAccountName se we had two opportunities
@b3m2a1 if it goes about the code formating I don't know where do you copy yours from but this is the pain to look at. quality/readability tends to infinity here ;)
 
That's what I aim for. It's my coding signature, you know?
If the code is impenetrable and full of bugs you know it's mine
 
 
2 hours later…
10:23 PM
I learned to program from a physicist and using Fortran 77. I know my style is ugly.
 
@chuy (almost) all scientist code is ugly :) It's amazing any of it works at all.
 
just keep adding spaces at the start of a line until it does work.
 

« first day (2575 days earlier)      last day (1906 days later) »