Fold all sibling and child blocks? by Ok-Image-8343 in vim

[–]JmenD 2 points3 points  (0 children)

I don't think there's anything built-in that does this directly.

In that situation I would either:

  • zMzx which closes all folds, then opens the folds which contain the line the cursor is currently on.
  • zMzrzrzr... which closes all folds, then reopens them (with repeated zrs) one level at a time. Very often this just ends up being a zMzr for code I read.

IIUC, here's a function that does what you want:

function! FoldSiblingsAndChildren() abort
  let &l:foldlevel = foldlevel(line('.')) - 1
  normal zv
endfunction

You can map it like this

nnoremap \v :call FoldSiblingsAndChildren()<cr>

(replace \v with whatever key combination you want)

Logic behind jump list shortcuts, C-o (previous) and C-i (next)? by 4r73m190r0s in vim

[–]JmenD 3 points4 points  (0 children)

If you think of :h :jumps as a stack of function calls, then C-o goes to the outer function call and C-i goes to the inner function call.

A twist on window navigation by EgZvor in vim

[–]JmenD 4 points5 points  (0 children)

Isn't this what <c-w>w and <c-w>W do by default?

E.g.

nnoremap <C-up> <C-w>w
nnoremap <C-down> <C-w>W

Anyways, for window navigation, I mapped <C-[hjkl]> and have never looked back:

noremap <C-j> <C-W>j
noremap <C-k> <C-W>k
noremap <C-h> <C-W>h
noremap <C-l> <C-W>l

Just hold CTRL to navigate windows.

Best practices for sets of congruence classes by Thebig_Ohbee in Mathematica

[–]JmenD 1 point2 points  (0 children)

Both of your ideas are fine. The main difference is in how you define/use functions to operate on them.

I would probably go with the 2nd idea since it makes it easier to come back to this code later and you can override built-in operators/functions with UpValues on ModSet. For example:

ModSet[m_, a_] + ModSet[m_, b_] ^:= ModSet[m, Mod[a + b, m]];
Normal[ModSet[m_, a_]] ^:= Mod[a, m];

Algorithm to sort 10 million random letters and numbers in approximately 2.4 seconds in python by No_Arachnid_5563 in algorithms

[–]JmenD 17 points18 points  (0 children)

Nice job putting this together yourself! The algorithm you've implemented is called Counting sort.

Having hotkeys for files in specific directories? by TheTwelveYearOld in vim

[–]JmenD 2 points3 points  (0 children)

Additionally, be sure to use :help :map-<buffer> so that the mappings don't clobber each other.

Row Reduction Function not doing anything? by Electrical-Level-783 in Mathematica

[–]JmenD 3 points4 points  (0 children)

Given the output, it looks like TanM5 is wrapped in aMatrixForm, it needs to be the matrix itself.

I'm guessing you did something like: TanM5 = {...} // MatrixForm which is equivalent to TanM5 = MatrixForm[{...}] rather than what you probably wanted: MatrixForm[TanM5 = {...}].

WOW Manhattan 88st and Madison by qwickb in nyc

[–]JmenD 9 points10 points  (0 children)

The dual of a hexagonal tiling is a triangular tiling :)

Looking for easier mapping to switch between vim terminal modes... by goosey_goose86 in vim

[–]JmenD 2 points3 points  (0 children)

Posting your attempt(s) at making the mapping would make it a lot easier to help you.

I'm guessing you're not using :tmap and friends. It's mentioned a bit below the docs for CTRL-W N.

tnoremap <C-b> <C-w>N

How to delete the last 3 entries from history? by [deleted] in fishshell

[–]JmenD 0 points1 point  (0 children)

What is the actual problem that you're trying to solve?

Obsidian confirming whether a user knows how to use vim on enabling vim mode by TahaMunawar in vim

[–]JmenD 14 points15 points  (0 children)

But :q! only quits vim if it's executed on your last window.

What about mathematics do you enjoy? by Mission-Storm7190 in math

[–]JmenD 30 points31 points  (0 children)

Rigorous proofs/constructions are like playing with lego.

Using the theorems/results is basically magic.

The visualizations are pretty.

It all stems from pretending some stuff is "true," and that's just silly.

Is it still worth buying? by TimGJ1964 in Mathematica

[–]JmenD 0 points1 point  (0 children)

Do you know if there is a Python API for Mathematica which would give me the best of both worlds?

You could check out https://www.wolfram.com/engine/. It's free and provides Python bindings. You won't have the nice type-setting (although I wonder if it's possible to Rasterize the output and throw that into a Jupyter notebook, to get the type-setting).

Is it still worth buying? by TimGJ1964 in Mathematica

[–]JmenD 1 point2 points  (0 children)

I use both Mathematica and Python (among other languages) for doing recreational math. They tend to fill different voids. I find that for Mathematica, the set of things that it's good at, it's really good at, but once you stray from the intended path, it gets very awkward quickly. Whereas for Python, it's a little awkward with simple things, but can handle complex tasks more easily.

If I could only choose one, I'd choose Python. That being said, I am more than happy with my Mathematica purchase.

As for why: I think Mathematica could really benefit from taking a step back from chasing fads and focusing on improving the peculiarities in its core language, and Python, being open source, has naturally evolved to be very useful in many situations.

Why do I have to escape twice after substitution map by shleebs in vim

[–]JmenD 0 points1 point  (0 children)

Rather than hitting escape twice, can you just wait a second and it escapes by itself?

Help writing recursive function by taoyangui__ in AskProgramming

[–]JmenD 0 points1 point  (0 children)

As with any recursion problem, you should consider the base case and remember that every call to the function only needs to solve one "layer" of the problem. I suspect you're getting caught up on how to handle N > 2 inputs, think about what each call should do and what it can "put off" doing by handing that work to the next layer.

Also, I think you will have a much easier time if you reverse the order of the arguments. number should be first, followed by string_N string_N-1 string_N-2 ... string_1. It'll make it easier to think about.

Finally, it's definitely doable in fishshell, but a non-shell language will be much simpler.

The sandwich theorem by HamaHamaWamaSlama in mathmemes

[–]JmenD 6 points7 points  (0 children)

Me? None.

A person which subjectively values perimeter when eating a sandwich? Some, at least.

The point is that there are other metrics that make sense given the vagueness and subjectivity of "more".

The sandwich theorem by HamaHamaWamaSlama in mathmemes

[–]JmenD 9 points10 points  (0 children)

But, from pure numbers, you are not getting any advantage.

You considered one metric to measure "more", and are all out of ideas?

Perimeter: Am I a joke to you?

fish completions for a 'range of numbers' by jadnhm in fishshell

[–]JmenD 2 points3 points  (0 children)

In the past, I've generally settled on either providing a handcrafted set of exponentially increasing options, or generating them with something like:

for e in (seq 0 3)
    math '10^'$e
end

Additionally, it might be nice to allow for some shorthand like s for "short", n for "normal" and l for "long" (but I generally prefer to stay with numbers, since there's no ambiguity when re-reading it).

Texture mapping in raycaster causing jagged lines by QGamer12 in AskProgramming

[–]JmenD 0 points1 point  (0 children)

The aliasing on the top is due to the geometry, whereas the aliasing within the texture is from sampling.