In Dyalog APL there is ⎕ML which changes how partition operates.
When ⎕ML←0
(5 ⍴ 1 0) ⊂ 5 5 ⍴ ⍳25
┌→─────────────────────┐
│ ┌→────┐ ┌→────┐ ┌→─┐ │
│ ↓ 1 2│ ↓ 3 4│ ↓ 5│ │
│ │ 6 7│ │ 8 9│ │10│ │
│ │11 12│ │13 14│ │15│ │
│ │16 17│ │18 19│ │20│ │
│ │21 22│ │23 24│ │25│ │
│ └~────┘ └~────┘ └~─┘ │
└∊─────────────────────┘
For the same statement (5 ⍴ 1 0) ⊂ 5 5 ⍴ ⍳25 in GNU APL
┏→━━━━━━━━━━━━━┓
↓┏→┓ ┏→┓ ┏→┓ ┃
┃┃1┃ ┃3┃ ┃5┃ ┃
┃┗━┛ ┗━┛ ┗━┛ ┃
┃┏→┓ ┏→┓ ┏→━┓┃
┃┃6┃ ┃8┃ ┃10┃┃
┃┗━┛ ┗━┛ ┗━━┛┃
┃┏→━┓ ┏→━┓ ┏→━┓┃
┃┃11┃ ┃13┃ ┃15┃┃
┃┗━━┛ ┗━━┛ ┗━━┛┃
┃┏→━┓ ┏→━┓ ┏→━┓┃
┃┃16┃ ┃18┃ ┃20┃┃
┃┗━━┛ ┗━━┛ ┗━━┛┃
┃┏→━┓ ┏→━┓ ┏→━┓┃
┃┃21┃ ┃23┃ ┃25┃┃
┃┗━━┛ ┗━━┛ ┗━━┛┃
┗∊━━━━━━━━━━━━━┛
Dyalog APL also does this when ⎕ML←3
Is there a way to alter how GNU APL behaves to obtain the same behaviour?
The short answer is no, because GNU APL follows IBM APL2 language conventions.
The core APL language was developed and perfected by the mid 1970s. However, Nested Arrays started coming a bit later, perhaps the first preliminary sneak peek implementations came out starting around 1980.
The major players at the time were IBM, I. P. Sharp Associates, STSC, and Dyalog, a relative newcomer. All nested array implementations differed in one detail or another, arguably the biggest such difference was the implementation of boxed arrays by Sharp which were the basis of the boxed array implementation found today in J.
Arguably, at the time, Mainframe IBM APL2 probably had the largest market share.
STSC would later change its name to Manugistics and the implementation would evolve into APL2000's APL+ product suite.
Both STSC and Dyalog provided some compatibility mode around the various nested array subspecies, STSC's was the )EVLEVEL system command, evolution level, and Dyalog's was []ML, migration level.
In a nutshell, Dyalog's []ML can be set to 0, 1, 2, or 3. From Dyalog's documentation,
[]ML 0 is the default native Dyalog nested array implementation
[]ML 1 changes the definition of monadic epsilon to be the "enlist" function, a kind of super-ravel
[]ML 2 swaps the definitions of the symbols used for the "first" and "mix" functions, plus presents an alternate definition of the "depth" function
[]ML 3 provides IBM APL2 compatibility.
Personally, I use []ML 3 almost exclusively, as I programmed heavily in APL2 when mainframes were still around.
Again, GNU APL follows IBM APL2 language compatibility. One way to achieve alternate enclose behaviours is to write cover functions to emulate the specialities of other implementations.
Related
I don't have a good understanding of COW-snapshots mechanics but expect they contain the diffs and shared data among all of those which have one parent subvolume.
I made a script to check btrfs snapshots disk space consumption.
#!/usr/bin/zsh
for i in {1..2000}
do
echo 'line'$i >> /btrfs/test-volume/btrfs-doc.txt
/usr/bin/time -f "execution time: %E" btrfs subvolume snapshot /btrfs/test-volume /btrfs/snapshots/test-volume-snap$i
done
After running i displayed their dirs size and what i got:
❯ btrfs filesystem df /btrfs
Data, single: total=8.00MiB, used=6.84MiB
System, DUP: total=8.00MiB, used=16.00KiB
Metadata, DUP: total=102.38MiB, used=33.39MiB
GlobalReserve, single: total=3.25MiB, used=0.00B
❯ btrfs filesystem du -s /btrfs
Total Exclusive Set shared Filename
18.54MiB 6.74MiB 36.00KiB /btrfs
❯ df -h /btrfs
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgstoragebox-btrfs 2.0G 77M 1.8G 5% /btrfs
❯ du -sh /btrfs
20M /btrfs
❯ ll /btrfs/test-volume/btrfs-doc.txt
-rw-r--r-- 1 root root 17K Jul 6 14:50 /btrfs/test-volume/btrfs-doc.txt
❯ tree -hU /btrfs/snapshots
/btrfs/snapshots
├── [ 26] test-volume-snap1
│ └── [ 6] btrfs-doc.txt
├── [ 26] test-volume-snap2
│ └── [ 12] btrfs-doc.txt
├── [ 26] test-volume-snap3
│ └── [ 18] btrfs-doc.txt
...
├── [ 26] test-volume-snap1998
│ └── [ 16K] btrfs-doc.txt
├── [ 26] test-volume-snap1999
│ └── [ 16K] btrfs-doc.txt
└── [ 26] test-volume-snap2000
└── [ 16K] btrfs-doc.txt
2000 directories, 2000 files
All the utils calculated size differently, i can't say how much disk space /btrfs/snapshots dir consumed actually, but i see it's much bigger than at least a double size of the file /btrfs/test-volume/btrfs-doc.txt. At the moment i think it should be around the double size in case the btrfs snapshots contain the diffs and shared data is linking.
In comparison, i made the same test with LVM snapshots and small disk space was consumed by them.
From a userland perspective btrfs snapshots are just simple directories containing the files and contents of the subvolume at the time the snapshot was created. You can access them normally like any other directory.
Therefore the userland tools you used will report the sizes of the individual files within the snapshot just as with any other file.
If you create say 10 snapshots of the same subvolume the userland tools such as du will report the same total size for each snapshot, and summarizing this for all 10 snapshots will report a disk usage of 10 times the size of the initial subvolume.
But: due to the CoW-nature of these subvolumes the contained files within the snapshots actually all share the same data blocks on disk. So although du will report 10 times the total size it is only used up on disk once.
The way Copy-on-Write works is that a new copy of a file (e.g. with created cp --reflink) or new snapshot is at first nothing more than a new pointer to the same physical data on disk as the original file/subvolume. So the new file will not use any additional disk space (besides some additional metadata).
Only when the data is changed the new additional data is written to a new place on the disk an the pointer of the file/snapshot is updated to include that data block. All unchanged parts of the data are still shared with the original copy.
This is why creating snapshots is very fast and uses next to no additional disk space. But over time the disk space used by a snapshot may grow since its reference data blocks diverge from the original subvolume and less and less data block will actually be shared.
If you want to see the amount of data that is shared between/unique to the individual subvolumes you can use the quota support feature of btrfs.
It all started with the fact that at some point Pluto did not start, giving an error for incompatibility with some package. I removed several packages that seemed to me a possible source of problems, and started updating the packages, as a result of which I received a complaint about incompatibility with a specific package. I also deleted it - I received a complaint on the next one, and so on several times. The situation turned out to be too complicated and I completely deleted the directory with the packages and installed them again. But the mistake was repeated again. Now I have recorded everything in more detail. First, Pluto gave an error in connection with package "FuzzyCompletions" that I did not specifically install:
Warning: Reading WebSocket client stream failed for unknown reason:
│ parentbody = Dict{Any,Any} with 5 entries: …
│ exception =
│ TaskFailedException:
│ On worker 2:
│ LoadError: Unsatisfiable requirements detected for package FuzzyCompletions [fb4132e2]:
│ FuzzyCompletions [fb4132e2] log:
│ ├─FuzzyCompletions [fb4132e2] has no known versions!
│ └─restricted to versions 0.3-0.4 by an explicit requirement — no versions left
│ check_constraints at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\Resolve\graphtype.jl:935
│ Graph at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\Resolve\graphtype.jl:362
│ deps_graph at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\Operations.jl:502
│ resolve_versions! at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\Operations.jl:374
│ up at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\Operations.jl:1222
│ #up#106 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\API.jl:245
│ #up#38 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\API.jl:68 [inlined]
│ #instantiate#170 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\API.jl:810
│ instantiate at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\API.jl:795
│ top-level scope at C:\Users\ten\.julia\packages\Pluto\luIaC\src\runner\Loader.jl:22
│ include at .\client.jl:457
│ top-level scope at none:1
│ eval at .\boot.jl:331
│ #103 at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Distributed\src\process_messages.jl:290
│ run_work_thunk at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Distributed\src\process_messages.jl:79
│ run_work_thunk at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Distributed\src\process_messages.jl:88
│ #96 at .\task.jl:356
│ in expression starting at C:\Users\ten\.julia\packages\Pluto\luIaC\src\runner\Loader.jl:1
│ Stacktrace:
│ [1] sync_end(::Channel{Any}) at .\task.jl:314
│ [2] macro expansion at .\task.jl:333 [inlined]
│ [3] remotecall_eval(::Module, ::Array{Int64,1}, ::Expr) at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Distributed\src\macros.jl:218
│ [4] create_workspaceprocess(; compiler_options::Pluto.Configuration.CompilerOptions) at C:\Users\ten\.julia\packages\Pluto\luIaC\src\evaluation\WorkspaceManager.jl:170
│ [5] make_workspace(::Tuple{Pluto.ServerSession,Pluto.Notebook}) at C:\Users\ten\.julia\packages\Pluto\luIaC\src\evaluation\WorkspaceManager.jl:43
│ [6] #7 at C:\Users\ten\.julia\packages\Pluto\luIaC\src\evaluation\WorkspaceManager.jl:188 [inlined]
│ [7] macro expansion at C:\Users\ten\.julia\packages\Pluto\luIaC\src\evaluation\Tokens.jl:76 [inlined]
│ [8] (::Pluto.var"#1#2"{Pluto.WorkspaceManager.var"#7#9"{Tuple{Pluto.ServerSession,Pluto.Notebook}},Pluto.Promise{Pluto.WorkspaceManager.Workspace}})() at .\task.jl:356
│ Stacktrace:
│ [1] wait at .\task.jl:267 [inlined]
│ [2] wait(::Pluto.Promise{Pluto.WorkspaceManager.Workspace}) at C:\Users\ten\.julia\packages\Pluto\luIaC\src\evaluation\Tokens.jl:83
│ [3] get_workspace at C:\Users\ten\.julia\packages\Pluto\luIaC\src\evaluation\WorkspaceManager.jl:190 [inlined]
│ [4] (::Pluto.var"#204#206")(::Pluto.ServerSession, ::Dict{Any,Any}, ::Pluto.Notebook; initiator::Pluto.Initiator) at C:\Users\ten\.julia\packages\Pluto\luIaC\src\webserver\REPLTools.jl:92
│ [5] process_ws_message(::Pluto.ServerSession, ::Dict{Any,Any}, ::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at C:\Users\ten\.julia\packages\Pluto\luIaC\src\webserver\WebServer.jl:357
│ [6] (::Pluto.var"#215#225"{Pluto.ServerSession,Base.RefValue{Function}})(::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at C:\Users\ten\.julia\packages\Pluto\luIaC\src\webserver\WebServer.jl:160
│ [7] upgrade(::Pluto.var"#215#225"{Pluto.ServerSession,Base.RefValue{Function}}, ::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}; binary::Bool) at C:\Users\ten\.julia\packages\HTTP\IAI92\src\WebSockets.jl:160│ [8] upgrade at C:\Users\ten\.julia\packages\HTTP\IAI92\src\WebSockets.jl:142 [inlined]
│ [9] (::Pluto.var"#214#224"{Pluto.ServerSession,HTTP.Handlers.Router{Symbol("##280")},Base.RefValue{Function}})(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at C:\Users\ten\.julia\packages\Pluto\luIaC\src\webserver\WebServer.jl:147
│ [10] handle at C:\Users\ten\.julia\packages\HTTP\IAI92\src\Handlers.jl:269 [inlined]
│ [11] #4 at C:\Users\ten\.julia\packages\HTTP\IAI92\src\Handlers.jl:345 [inlined]
│ [12] macro expansion at C:\Users\ten\.julia\packages\HTTP\IAI92\src\Servers.jl:367 [inlined]
│ [13] (::HTTP.Servers.var"#13#14"{HTTP.Handlers.var"#4#5"{HTTP.Handlers.StreamHandlerFunction{Pluto.var"#214#224"{Pluto.ServerSession,HTTP.Handlers.Router{Symbol("##280")},Base.RefValue{Function}}}},HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at .\task.jl:356
└ # Pluto C:\Users\ten\.julia\packages\Pluto\luIaC\src\webserver\WebServer.jl:168
During the initial installation of the packages, there were no errors or warnings, this error was the first one
I decided to try to remove Pluto and run the update, but after that I got the following error:
julia> Pkg.rm("Pluto")
Updating `C:\Users\ten\.julia\environments\v1.5\Project.toml`
[c3e4b0f8] - Pluto v0.12.18
Updating `C:\Users\ten\.julia\environments\v1.5\Manifest.toml`
[fb4132e2] - FuzzyCompletions v0.4.0
[99f44e22] - MsgPack v1.1.0
[c3e4b0f8] - Pluto v0.12.18
julia> Pkg.update()
ERROR: Unsatisfiable requirements detected for package Distributions [31c24e10]:
Distributions [31c24e10] log:
├─Distributions [31c24e10] has no known versions!
└─restricted to versions * by an explicit requirement — no versions left
Deleted it, and got a claim to the next package:
julia> Pkg.rm("Distributions")
Updating `C:\Users\ten\.julia\environments\v1.5\Project.toml`
[31c24e10] - Distributions v0.24.10
No Changes to `C:\Users\ten\.julia\environments\v1.5\Manifest.toml`
julia> Pkg.update()
ERROR: Unsatisfiable requirements detected for package CSV [336ed68f]:
CSV [336ed68f] log:
├─CSV [336ed68f] has no known versions!
└─restricted to versions * by an explicit requirement — no versions left
Deleted it, and got a claim to the next package:
julia> Pkg.rm("CSV")
Updating `C:\Users\ten\.julia\environments\v1.5\Project.toml`
[336ed68f] - CSV v0.8.2
No Changes to `C:\Users\ten\.julia\environments\v1.5\Manifest.toml`
julia> Pkg.update()
ERROR: Unsatisfiable requirements detected for package DataFrames [a93c6f00]:
DataFrames [a93c6f00] log:
├─DataFrames [a93c6f00] has no known versions!
└─restricted to versions * by an explicit requirement — no versions left
Perhaps it would be possible to continue this way, but it is obvious that this would not solve the problem. So I stopped and decided to ask for advice
All the packages I use are pretty standard. Here is the current status of what is left after the deletion:
julia> Pkg.status()
Status `C:\Users\ten\.julia\environments\v1.5\Project.toml`
[dcc97b0b] GeoStats v0.21.0
[916415d5] Images v0.23.3
[682c06a0] JSON v0.21.1
[91a5bcdd] Plots v1.10.1
[7f904dfe] PlutoUI v0.6.11
[92933f4c] ProgressMeter v1.4.1
[6f49c342] RCall v0.13.10
[de0858da] Printf
[9a3f8284] Random
[10745b16] Statistics
I have not found any recipes for what to do in the case of such cascading accidents and what may be their cause. If I did something wrong, I'm ready to once again completely tear down the packages folder and install them again. But it seems that I do not understand the reasons for what is happening, so I would like to understand the nature of this phenomenon, so that this does not happen again in the future
As I already wrote in the comments the problem probably lies in the Julia registry.
To have a broader insight on what registries are and how they work you might give a look at the Documentation.
To check the status of the registry you can use (within the REPL) ] registry status and to update it ] registry update.
However, there might got something broken. Then you can delete and add the registry back.
This is done by:
pkg> registry rm General
pkg> registry add https://github.com/JuliaRegistries/General
where pkg> is the Pkg.jl REPL that you enter with a ].
I am trying out ncurses programming in C on Linux (Mint) and am having a strange problem. I keep getting windows with the wrong number of columns for the first and final lines. For example, with this code found on StackOverflow
#include <ncurses.h>
int main(){
initscr();
WINDOW * win = newwin(10,50,10,10);
box(win,0,0);
wrefresh(win);
wgetch(win);
endwin();
return 0;
}
I get this output:
┌─┐
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└─┘
As if the first and final lines are only three columns wide. If I add text to the window, using waddch, I can only add three characters to the top line as well.
Any help would be appreciated, I can't find examples of other people running into this issue on the web, but it's not the easiest thing to come up with a good search string for.
Looks like you're using one of those xterm look-alikes, and running into their omission of repeat-character, noted a little over a year ago in the ncurses FAQ.
I want to make nice tables like you see on some manual page of Linux documentation
in C programming language. Is there any library or functions to create a table like them.
For example a table that you can find on man syslog like the following, produced by running man syslog:
┌──────────────────────┬───────────────┬────────────────────┐
│Interface │ Attribute │ Value │
├──────────────────────┼───────────────┼────────────────────┤
│openlog(), closelog() │ Thread safety │ MT-Safe │
├──────────────────────┼───────────────┼────────────────────┤
│syslog(), vsyslog() │ Thread safety │ MT-Safe env locale │
└──────────────────────┴───────────────┴────────────────────┘
This was probably done with "tbl". See man tbl. Also see the L. L. Cherry
and M. E. Lesk document "Tbl — A Program to Format Tables" which can be found via Google.
An example
This file:
$ cat f.tbl
.TS
allbox;
c s s
c c c
n n n.
AT&T Common Stock
Year Price Dividend
1984 15-20 $1.20
5 19-25 1.20
6 21-28 1.20
7 20-36 1.20
8 24-30 1.20
9 29-37 .30*
.TE
* (first quarter only)
Produced this (with tbl f.tbl > f.troff; nroff f.troff):
┌────────────────────────┐
│ AT&T Common Stock │
├─────┬───────┬──────────┤
│Year │ Price │ Dividend │
├─────┼───────┼──────────┤
│1984 │ 15‐20 │ $1.20 │
├─────┼───────┼──────────┤
│ 5 │ 19‐25 │ 1.20 │
├─────┼───────┼──────────┤
│ 6 │ 21‐28 │ 1.20 │
├─────┼───────┼──────────┤
│ 7 │ 20‐36 │ 1.20 │
├─────┼───────┼──────────┤
│ 8 │ 24‐30 │ 1.20 │
├─────┼───────┼──────────┤
│ 9 │ 29‐37 │ .30* │
└─────┴───────┴──────────┘
* (first quarter only)
You can take a look at the ncurses library here: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/
I am attempting to convert the following CFG to a pushdown automaton:
S → AS | A
A → 0A | 1B | 1
B → 0B | 0
I'm not really sure how to approach this problem, or the problem of CFG->PDA in general.
Conversation of Context free grammar to Pushdown automata:
Steps to convert CFG to Pushdown automata:
Step-1:The first symbol on R.H.S. production must be a terminal symbol.
Step-2:Convert the given productions of CFG into GNF.
Step-3:The PDA will only have one state {q}.
Step-4:The initial symbol of CFG will be the initial symbol in the PDA.
Step-5:For non-terminal symbol, add the following rule:
δ(q, ε, A) = (q, α)
Where the production rule is A → α.
Step-6:For each terminal symbols, add the following rule:
δ(q, a, a) = (q, ε) for every terminal symbol
You may use JFlap application to do it for you.
http://www.jflap.org/
Beyond this there are several other interesting functionalyties in that application that will help you study formal languages.
I've been using it for about two weeks and I'm loving it.