Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectors, lists and multiline summations #23

Open
progo opened this issue Apr 20, 2021 · 1 comment
Open

Vectors, lists and multiline summations #23

progo opened this issue Apr 20, 2021 · 1 comment

Comments

@progo
Copy link

progo commented Apr 20, 2021

This package is the coolest! Ever since hearing about a mac app Soulver, I've yearned for a free literate calculator for linux. So thank you for having the vision of combining the powerhouse that is calc and making a well-working implementation. :)

I immediately made this helper function to have quick access to a quick scribble when needed.

  (defun pop-calculator ()
    (interactive)
    (switch-to-buffer (get-buffer-create "*literate-calc*"))
    (literate-calc-mode))

But now to the question. Please keep in mind that I am not a calc expert so I am partly thinking about a feature request but also like to hear about what calc the backend can do here without any further development.

I like making lists and summing them up. Traditionally a job for org tables or perhaps the ses-mode, I like the fluency of a list within free text.

But understandably we don't have a multiline support so we're left with these approaches:

a = 10 => a: 10
a = a + 10 => a: 20
a = a + 20 => a: 40

b = [1 2 4] => b: [1, 2, 4]

= a => 40
= vsum(b) => 7

Perhaps I just don't necessarily like the repeated use of the variable name. += would be an obvious idea to consider. I thought about other kinds of multiline supports for vectors but inline comments are valuable to me and now things would definitely get too complex and unpredictable.

Maybe the purpose of this ticket is just to say thanks for a great library.

@sulami
Copy link
Owner

sulami commented Jun 21, 2021

Hey,

Sorry for sitting on this forever, busy days.

I'm also not a calc expert by any means, though this project has already taught me a lot about calc. It's not quite as concise, but vconcat exists to collect vectors.

x = [4 8 15] => x: [4, 8, 15]
y = [16 23 42] => y: [16, 23, 42]
z = vconcat(x, y) => z: [4, 8, 15, 16, 23, 42]
= vsum(z) => 108

Actual multiline support would be hard to add, as LCM relies on a line-by-line evaluation model, which I would also like to keep because it is easy to test, and in the future could maybe even be done in parallel for better performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants