don't you love it when you have to learn two programming languages for one assignment?
you can do some funny lisp playground stuff in emacs' `*scratch*` buffer, opened like so
take a look at emacs' `what-line` command (run with `M-x what-line`) and notice that it outputs the current line number, but not how many lines are in the file total
how about we fix that? make a file `gps-line.el` that contains a lisp function `what-line` that outputs the following
``` Line [x]/[n] ```
where `[x]` should just be the line you're currently at and `[n]` is the total number of lines in the buffer
visit `what-line`'s source code to see how it works!
to count the total number of lines, you should just get the buffer and count the number of newline characters
due to this specification, your function should be able to say things like `Line 1/0` when called on some text
that doesn't end in a newline
to give you an idea of what this file might look like, here's the general structure of my `gps-line.el`
```lisp (defun gps-line() (interactive) (message "do some stuff here")) ```
if you look at the source code for `what-line`, you'll see that there's some special logic for "narrowed buffers"
or whatever the hell
i would recommend implementing support for that just in case, since the code is pretty copy and paste-able for that
you should be able to load the file and the function within by typing `M-:` (really `M-shift-;`) and running this: ```lisp (load "gps-line.el") ``` or you can follow this guide to load it in on startup
honestly wonder what proportion of a 35l class knows python already
but anyways there's three versions of python on the seasnet servers that are of relevance to this part
any questions that require running code or whatever, i'd recommend you do them on there
consider the following script randline (WINTER 24 VERSION, MAY BE OUTDATED)
code up a python 3 script `shuf.py` that mimics the default `shuf` command
it should implement the following options:
these descriptions aren't comprehensive- consult the man pages or just run it yourself to see how things actually work
as of winter 24, you can only import from `argparse`, `string`, and the non-`optparse` modules already imported in the `randline` script
my friends and i found a ton of edge cases that you might wanna test, since the default `shuf` has some behavior that might differ a bit from `argparse`
```bash shuf -e asdf -r # should output "asdf" forever shuf asdf -i 6-10 # should error, since 6-10 was already given as an input range shuf thing.txt what.txt # ditto, except this time the input file was already given shuf -i -1-10 # this errors, you should only handle nonnegative integers for -i shuf -e -asdf # you'd think this'd print "-asdf". nope! it errors ```