Live data from Hacker News

Designing a programming language to speedrun Advent of Code

blog.vero.site

81–90 of 101 posts

Re: Designing a programming language to speedrun Advent of Code

#81
post #7

> I solve and write a lot of puzzlehunts, and I wanted a better programming language to use to search word lists for words satisfying unusual constraints, such as, “Find all ten-letter words that contain each of the letters A, B, and C exactly once and that have the ninth letter K.” So... Perl?

    sls '^........k.$' .\wordlist.txt -raw |where { $W=$_;
      ('a','b','c' |where
         { $W.Contains($_) -and $W.IndexOf($_) -eq $W.LastIndexOf($_) }
       ).Count -eq 3 }

Re: Designing a programming language to speedrun Advent of Code

#82

I think it’s interesting how similar a lot of this stuff is to what I do, except I’m not very good at Advent of Code and also I decided to hack Python to do this instead of writing my own language. For example: * I couldn’t really make operators first class functions, but I just autoimported operator which has this but in words * I wanted partial application and hated lambda syntax, so I hacked it together with some…

Ever played with a more stack-oriented / concatenative / postfix language, like Factor?

  "," split [ string>number 5 > ] count
or

  "," split [ string>number ] map [ 5 > ] count
or

  "," split [ string>number 5 > ] filter length

Re: Designing a programming language to speedrun Advent of Code

#83
post #15

Earlier quoted context omitted.

Talking of shell, the preference for left-to-right is often used to justify "useless use of cat", i.e. `cat file | command` instead of `command <file`, but it can just be written `<file command` instead.

Is `<file` shorthand for `cat file`, or is that only true when used in a sub-shell?

In that fun way that shells are, for bare redirection it depends.

In bash/ksh, it matches frou_dh's explanation. In zsh, it depends on how you've set the various *NULLCMD options and parameters. In csh, it is an error.

Even in zsh, when configured to behave like `cat file` it still doesn't quite do that as it won't concatenate files as it only passes the first shell word following the `<` to `cat`(or whatever you've set NULLCMD to). Guess that means you could be evil by making a wrapper that allows weird Unicode separators to pass multiple files in one word to get the concatenation back ;)

Re: Designing a programming language to speedrun Advent of Code

#84

Earlier quoted context omitted.

To be clear by “standard library” I mean that Python has like actual data structures that are useful. Also while not part of the standard library arbitrary precision integers and associated functions (e.g. modular pow) can be quite helpful.

Javascript now has Map, Set, and bigint. But no powmod.

Python also has niceties like defaultdict or heapq

Re: Designing a programming language to speedrun Advent of Code

#85
post #76

I think it’s interesting how similar a lot of this stuff is to what I do, except I’m not very good at Advent of Code and also I decided to hack Python to do this instead of writing my own language. For example: * I couldn’t really make operators first class functions, but I just autoimported operator which has this but in words * I wanted partial application and hated lambda syntax, so I hacked it together with some…

I think Ruby might be your next language :) But I do do the following sort of thing in Python: ``` from chainzzz import C C(some_list).group_by(lambda x: x + 1).map(lambda key: key % 2).size() ``` Where C(...) gives us the same object but with some methods added to it as you can see

Hmm, that's an interesting way of doing it. I'll keep it in my back pocket if they ever break this :)

Re: Designing a programming language to speedrun Advent of Code

#86
post #38

Earlier quoted context omitted.

Is `<file` shorthand for `cat file`, or is that only true when used in a sub-shell?

I guess it's equivalent to `: <file` i.e. hooking up the stdin of the no-op command.

Doesn't seem to be the case. For example, `< file cat` shows the file, whereas `: < file cat` or `: < file | cat` does nothing.

Re: Designing a programming language to speedrun Advent of Code

#87
post #86
post #38

Earlier quoted context omitted.

I guess it's equivalent to `: <file` i.e. hooking up the stdin of the no-op command.

Doesn't seem to be the case. For example, `< file cat` shows the file, whereas `: < file cat` or `: < file | cat` does nothing.

Not sure what's surprising you in those snippets. `:` itself is a command and it does nothing with its arguments or stdin.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...

Re: Designing a programming language to speedrun Advent of Code

#88
post #87
post #86

Earlier quoted context omitted.

Doesn't seem to be the case. For example, `< file cat` shows the file, whereas `: < file cat` or `: < file | cat` does nothing.

Not sure what's surprising you in those snippets. `:` itself is a command and it does nothing with its arguments or stdin. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...

I know. The only thing surprising me is your previous claim that `< file` is equivalent to `: < file`.

Re: Designing a programming language to speedrun Advent of Code

#89
post #88
post #87

Earlier quoted context omitted.

Not sure what's surprising you in those snippets. `:` itself is a command and it does nothing with its arguments or stdin. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...

I know. The only thing surprising me is your previous claim that `< file` is equivalent to `: < file`.

My interpretation of sgarland's question was that he meant `<file` being the entirety of the statement, i.e. typing only that at a shell prompt and pressing return.

Re: Designing a programming language to speedrun Advent of Code

#90
post #89
post #88

Earlier quoted context omitted.

I know. The only thing surprising me is your previous claim that `< file` is equivalent to `: < file`.

My interpretation of sgarland's question was that he meant `<file` being the entirety of the statement, i.e. typing only that at a shell prompt and pressing return.

Ah. Now I understand where the misunderstanding was. It confused me that we were talking about redirection as a replacement for useless use of cat.
Post reply on HN