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

command to turn a sequence into a column #2610

Open
midichef opened this issue Nov 14, 2024 · 3 comments
Open

command to turn a sequence into a column #2610

midichef opened this issue Nov 14, 2024 · 3 comments
Labels

Comments

@midichef
Copy link
Contributor

midichef commented Nov 14, 2024

How about a command to turn a sequence into a column, one element per row?

Something along the lines of:
Sheet.addCommand('', 'addcol-seq', 'seq_expr=inputExpr("seq expr: "); seq = eval(seq_expr, getGlobals()); c=SettableColumn(); addColumnAtCursor(c); c.setValues(rows, *seq)', 'add column with rows from a sequence')

vals = [5,4,3,2,1] addcol-seq vals
to create a column:

A
--
5
4
3
2
1

I'm not sure how to set the column type.

@midichef midichef changed the title command addcol-seq to have rows holding each element of a list in turn command to turn a sequence into a column Nov 14, 2024
@saulpw
Copy link
Owner

saulpw commented Nov 15, 2024

Is this the addcol-iter variant of setcol-iter (gz=)?

@midichef
Copy link
Contributor Author

Ah right, setcol-iter exists. This functionality felt very familiar, now I know why!

Then addcol-iter is just a shorthand for gs za colname setcol-iter col. But I do think it'd be helpful mentally to have a single command for that. What do people think?

One downside is that the exec-longname command palette for addcol- would get even more crowded. It has 4 commands that don't fit on screen with default settings. If we make addcol-iter, it'd have 5.

@frosencrantz
Copy link
Contributor

Given your answer #2613 (comment), this would be consistent with existing commands, and simplify the flow for such a task.

Wondering if there is an easier way to handle this matrix of commands (add|set)col-(expr|iter|incr|subs|regex-subs|...) that we have. They are useful, just wondering how to better invoke and find them.

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

No branches or pull requests

3 participants