Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for r~~
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #291668 |
Post edited: |
— | 7 months ago |
Edit | Post #291668 | Initial revision | — | 7 months ago |
Answer | — |
A: How is this code "dividing" by a string? You very likely have a `pathlib` `Path` (or `PurePath`) object there. `pathlib` overrides the division operator to perform platform-aware path appends. ```py >>> import pathlib >>> pathlib.Path('/foo') / 'bar' PosixPath('/foo/bar') ``` (more) |
— | 7 months ago |
Edit | Post #291555 | Initial revision | — | 7 months ago |
Answer | — |
A: Why is the `Data.Int` type not a `Semigroup` in PureScript but `String` is? > Is this for purely technical reasons as there would have to be at least 2 Semigroup instances (for addition and multiplication), but type classes cannot be implemented multiple times for the same type? Yes, basically this. When there is more than one plausible way to interpret a type as an insta... (more) |
— | 7 months ago |
Comment | Post #291533 |
Can you reproduce this with no other syntax rules in the buffer (you can clear the current buffer with `:syntax clear`)? I'm unable to but I'm using Neovim.
If not, can you use that to find the rule that conflicts? (more) |
— | 7 months ago |
Edit | Post #291514 | Initial revision | — | 7 months ago |
Answer | — |
A: How to iterate over numpy array axes in array slicing? `slice(None)` will give you a value that's equivalent to a bare `:` in slice syntax. So you can write, for example, ```python for i in range(4): print(newarray[tuple(slice(None) if i == j else n for j, n in enumerate([0,1,2,3]))]) ``` (more) |
— | 7 months ago |
Edit | Post #291490 | Initial revision | — | 7 months ago |
Answer | — |
A: In javascript is there really a good reason to never check for boolean true || false such as if(var){}else{}? ``` if(typeof(var) !== 'undefined' || typeof(var) !== null || var !== ''){}else{} ``` is a wild thing to write for anything other than a variable that takes either undefined, null, or a string as possible values. If you expect `someVar` to be a boolean, I don't know who would tell you that `i... (more) |
— | 7 months ago |
Comment | Post #291228 |
Intuitively, sure, although it's not a very big intuitive leap if you have `bind h` and you know you want `bind (switch f)`. It's as mechanical as algebra once you're used to it. (more) |
— | 9 months ago |
Edit | Post #291228 |
Post edited: |
— | 9 months ago |
Edit | Post #291232 | Initial revision | — | 9 months ago |
Answer | — |
A: Why does `let map f = id >=> switch f` work in F#? > when I look at the type signatures, it is not supposed to work. The types work because they're parameterized. The types of the combinators involved are (renaming all parameters to be unique for clarity): ``` id : 'a -> 'a switch : ('b -> 'c) -> 'b -> Result (>=>) : ('d -> Result) -> ... (more) |
— | 9 months ago |
Edit | Post #291228 |
Post edited: |
— | 9 months ago |
Comment | Post #291228 |
I don't think this particular formulation is typical in other FPLs—the `switch` combinator is a bit unusual. But it follows easily from your other definitions; I'll expand my answer to detail how. (more) |
— | 9 months ago |
Edit | Post #291228 | Initial revision | — | 9 months ago |
Answer | — |
A: How to implement `map` using the fish (>=>, Kleisli composition) operator in F#? > Is there a "cleaner" implementation similar to `map`'s? Yes: ``` let map f = id >=> switch f ``` This follows from two of your other equations: ``` map f = bind (switch f) g >=> h = g >> bind h ``` So if you want to get `bind (switch f)` out of `(>=>)`, you can start by making `... (more) |
— | 9 months ago |
Edit | Post #290805 | Initial revision | — | 10 months ago |
Answer | — |
A: Why does `Zip` require `Semialign` There's good reason to believe this is simply historical accident. The `Semialign` class came first, and used to include `zip` and `zipWith` directly. When those members were separated out into their own class, the motivation was types that had `align` but not `zip` (one example is `NEMap`), so `Zip`... (more) |
— | 10 months ago |
Edit | Post #290338 | Initial revision | — | about 1 year ago |
Answer | — |
A: What does "namespace" mean? A namespace is a category to which a name can belong. Think of family names for people: I may be friends with several Jims, and if only one of them is present I can just call him Jim. But if multiple are present, I can disambiguate which I mean by saying Jim Jones or Jim Smith. ‘Jones’ and ‘Smith’ ar... (more) |
— | about 1 year ago |
Comment | Post #290250 |
Have you read https://software.codidact.com/help/formatting? (more) |
— | about 1 year ago |
Comment | Post #290032 |
Yes, for a new file you need to run `git add -N foo.txt` first (short for `git add --intent-to-add`). This adds the file to the index but without any content, which allows `git add -p` to make a diff containing the whole file. (more) |
— | about 1 year ago |
Edit | Post #289969 | Initial revision | — | about 1 year ago |
Answer | — |
A: Set transform of SVG element `` does seem to be a bit finicky for this case, doesn't it? You can use `` if you set the `values` attribute on it instead of the `to` attribute, like this: ``` ``` (more) |
— | about 1 year ago |
Comment | Post #289831 |
After over a century of use, it's *not* an analogy, meaning ‘to behave like an electrical short circuit’; it's an idiom, meaning ‘to bypass’. Judging a newer application of the idiom by the etymological source of the idiom is kind of counter to the way language works, I think. (more) |
— | about 1 year ago |
Comment | Post #289831 |
I think you're overthinking the short-circuit connection to electrical engineering. ‘Short-circuit’ has been in use as a figurative expression meaning ‘to bypass’ in non-EE contexts since [at least 1900](https://www.google.com/books/edition/Intestinal_Obstruction/HzI4AQAAMAAJ?hl=en&gbpv=1&pg=PA530&pr... (more) |
— | about 1 year ago |
Edit | Post #289579 |
Post edited: revert meddling |
— | over 1 year ago |
Comment | Post #289628 |
I've not used Crossfilter before, but from scanning the documentation I would assume that this is a group in the sense of SQL's [`GROUP BY` statement](https://en.wikipedia.org/wiki/Group_by_(SQL)). (more) |
— | over 1 year ago |
Comment | Post #289605 |
A quick internet search for Python libraries that handle keystrokes should provide plenty of results that would be relevant for this problem. If you have one in mind already, perhaps ask a question that targets a specific difficulty you've had with it; otherwise, this question doesn't have enough evi... (more) |
— | over 1 year ago |
Comment | Post #289584 |
This feature is called ‘hijacking your users' paste function to do something they probably weren't expecting’. Many users don't like this.
If you're writing this just for yourself, or for a small audience whose tastes you know well, go in peace. If you're writing this for a public website, please ... (more) |
— | over 1 year ago |
Edit | Post #289595 | Initial revision | — | over 1 year ago |
Answer | — |
A: Is it okay to use python operators for tensorflow tensors? No, you can't use `and` for this. In Python, `a and b` always, always, always means `b if a else a`. It cannot be overridden and cannot mean anything else. Likewise `not`, and any other boolean keywords, as opposed to operators. You could instead write `a & b`, which should mean the same thing ... (more) |
— | over 1 year ago |
Edit | Post #289579 |
Post edited: |
— | over 1 year ago |
Comment | Post #289579 |
Maybe not ‘reasonably simple’, but I've added a solution that uses `walk` without defining a new function. I don't think you'll be able to do better than this, without cutting some corners in terms of what inputs you accept. (more) |
— | over 1 year ago |
Edit | Post #289579 |
Post edited: |
— | over 1 year ago |
Edit | Post #289579 | Initial revision | — | over 1 year ago |
Answer | — |
A: Replace leaf arrays with joined strings in a nested structure in jq As the `walk` documentation describes: > When an array is encountered, f is first applied to its elements and then to the array itself In other words, `walk` is bottom-up. So when you apply your filter to your nested-array input, first you're flattening the innermost arrays into strings. Then ... (more) |
— | over 1 year ago |
Edit | Post #289513 | Initial revision | — | over 1 year ago |
Answer | — |
A: How can I schedule a later task in Python? If `systemd-run` works for you, that is probably the simplest thing you can do here. Otherwise, you can use `os.fork()` from within Python to spawn a child that stays alive after the parent exits. If someone else is reading this based on the title, but is writing an industrial Python applicatio... (more) |
— | over 1 year ago |
Edit | Post #289512 | Initial revision | — | over 1 year ago |
Answer | — |
A: How can a Python program send itself to the background? Use `os.fork()`. Example: ```python import os import time pid = os.fork() if pid == 0: os.setsid() # Prevents the child from being killed if the parent dies time.sleep(10) os.system('somecmd') os.exit(os.EXOK) # This is important after a fork; otherwise Python cleans up it... (more) |
— | over 1 year ago |
Comment | Post #278211 |
That's not what I said. The general concept of answering your own questions isn't awkward, but it's an awkward *fit* for the existing usage patterns of a Q&A site. It doesn't integrate well into the system of voting on questions and answers individually, or the notifications that get generated on mul... (more) |
— | over 1 year ago |
Edit | Post #288100 | Initial revision | — | over 1 year ago |
Answer | — |
A: Is it possible to get the current function in a trace function? CPython only very recently started keeping a reference on frames to function objects internally, and that reference isn't exposed from inside Python. There's an old PEP that would have defined a `function` local, which, combined with the `flocals` field on frame objects, probably would have done w... (more) |
— | over 1 year ago |
Edit | Post #288035 | Initial revision | — | over 1 year ago |
Answer | — |
A: How do I get something similar to dictionary views, but for sequences? It isn't writable (but then again, neither are the dictionary views), but you might be interested in moreitertools.SequenceView. (more) |
— | over 1 year ago |
Edit | Post #287858 |
Post edited: |
— | almost 2 years ago |
Edit | Post #287858 | Initial revision | — | almost 2 years ago |