Hacker Newsnew | past | comments | ask | show | jobs | submit | shawn_w's commentslogin


Far right totalitarianism and far left totalitarianism have a lot in common.

Man I wish the Xenosaga games would get a rerelease for a modern console.

IIRC the GNU sed people looked into adding pcre support but decided it was too much work and that people should just use perl instead.

Or put the logo on a pivot so it's always right side up no matter the orientation of the laptop.

A bunch of Scheme implementations define little-known syntax for partial application[0] that lets you put limits on how many arguments have to be provided at each application step. Using the article's add example:

  (define (((add x) y) z) (+ x y z))
  (define add1 (add 1))
  (define add3 (add1 2))
  (add3 3) ; => 6
it gets tedious with lots of single-argument cases like the above, but in cases where you know you're going be calling a function a lot with, say, the first three arguments always the same and the fourth varying, it can be cleaner than a function of three arguments that returns an anonymous lambda of one argument.

  (define ((foo a b c) d)
    (do-stuff))
  (for-each (foo 1 2 3) '(x y z))
vs

  (define (foo a b c)
    (lambda (d) (do-stuff)))
  (for-each (foo 1 2 3) '(x y z))

There's also a commonly supported placeholder syntax[1]:

    (define inc (cut + 1 <>))
    (inc 2) ; => 3
    (define (foo a b c d) (do-stuff))
    (for-each (cut foo 1 2 3 <>) '(x y z))
And assorted ways to define or adapt functions to make fully curried ones when desired. I like the "make it easy to do something complicated or esoteric when needed, but don't make it the default to avoid confusion" approach.

[0]: https://srfi.schemers.org/srfi-219/srfi-219.html

[1]: https://srfi.schemers.org/srfi-26/srfi-26.html


perl, though that uses lists rather than multiple value or fixed-size tuples:

  #!/usr/bin/env perl
  use v5.36;
  
  sub f($a, $b) {
    return ($a+1, $b+1);
  }
  
  sub g($k, $l) {
    return ($k+1, $l+1);
  }
  
  say for f(g(1,2));
prints out

  3
  4

>The code from the book is exceedingly non-idiomatic lisp.

    (defconstant true t)
*twitch* You weren't kidding. I'd be tempted to rewrite it if I thought anyone would use it.

Well most of the local bindings are a single letter, so we gotta make sure booleans stand out!

You and me both (though I'm also annoyed by the overuse of macros instead of inline functions and the woeful lack of docstrings and type declarations).

Yeah, there's a lot of comments that should be docstrings.

And lots of lists that should be structures or classes...


Macros instead of inline functions is just archaic, not necessarily non-idiomatic. I'm not sure when inline declarations were added, but even well after that point macros were more reliable for getting inlining.

Calendrica has been around for that long already? How time flies. Was also interesting to find an off-by-1 bug in final (if the condition doesn't hold for initial the result is smaller than initial instead of greater than or equal to it). Interesting little program to read, though.

There's also a parallel version of bzip2, pbzip2.

https://man.archlinux.org/man/pbzip2.1.en

And zstd is multi threaded from the beginning.


Des Moines, WA vs Des Moines, IA.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: