Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Slurping a file




On 2024-01-14 02:34, Roman Perepelitsa wrote:

That's a master class.  I'm going to save that post and absorb  it even if it takes a month.

> Indeed, this would be faster but the code would still have quadratic time complexity. Here's a version with linear time complexity:

Quadratic? In this kind of situation I'd understand linear, geometric and exponential. What's quadratic? Hmmm .... to guess ... well yeah, you must mean some combination -- an exponential vector + a geometric vector + a linear vector, yes? My math skills aren't up to it, but they say there's a way of throwing a progression like those into an engine that returns the quadratic that best fits. Great fun if one could find it. Actually I did that once in Geogebra.

Please let me know when yourself and Bart have a final cut of slurp -- for a guy like me who thinks a copy should be a copy, not an edit, slurp seems an essential tool on principal. I can't understand how something so basic could not be built into the shell. Seems to me that at a first estimation one might want:

1) Full exact copy -- byte identical including blanks, newlines, trailing stuff and naughty chars. slurp.

2) Byte identical up to the last 'real' character -- yes, strip off any trailing garbage. This would be: > % copy=( "${(@f)original}" ) < , yes? Good enough 99% of the time.

3) As it is now -- no blanks. I myself have arrays in which blanks must be preserved ...

Hey ... How does all that work with associative arrays? It's one thing to remove a blank/empty element in a normal array, but in an A array ... even when there's no value, the keyword is still there, no? I'm thinking that A arrays must be auto-immune to removal of blank values, yes? But ...

main[currentE]=1 # Absolute index of the highlighted element (returned to calling fce on ENTER or mouse click). main[hilighted]=1 # RELATIVE index of the highlighted element relative to top of current page.

main[hilighted]= # Don't even think about doing this!

... I've noticed that if initializing an A array, there *must* be a value otherwise the pairs go out of whack. So, really, there never is an empty value and the issue is moot.



Messages sorted by: Reverse Date, Date, Thread, Author