Skip to content

Instantly share code, notes, and snippets.

@alex-ilin
Last active June 10, 2017 20:49
Show Gist options
  • Save alex-ilin/aac4f5b40c214ec96f4fe12a8caeea5e to your computer and use it in GitHub Desktop.
Save alex-ilin/aac4f5b40c214ec96f4fe12a8caeea5e to your computer and use it in GitHub Desktop.
Greater memory footprint due to `keys` and `map`
: first-column-width ( table model -- width )
value>> dup sequence? [
length 1 - 1array
] [
make-mirror keys
] if [ unparse-short ] map
over renderer>> column-titles first suffix
row-column-widths supremum ;
: <inspector-table> ( model -- table )
[
[ make-slot-descriptions ] <arrow> inspector-renderer <table>
[ invoke-primary-operation ] >>action
line-color >>column-line-color
6 >>gap
15 >>min-rows
15 >>max-rows
40 >>min-cols
40 >>max-cols
monospace-font >>font
dup
] keep first-column-width 0 2array >>fixed-column-widths ;
@alex-ilin
Copy link
Author

The proposed code would not work, because column-titles first returns the string "Key". I'd have to call cell-dim nip + on the string to be able to max it with the result of row-column-widths supremum. But calling cell-dim that way is what I'm trying to avoid by using the row-column-widths in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment