Andy

joined 2 years ago
MODERATOR OF
 
 

Animated preview

This is not my own project!

 

Discussion on HackerNews

 

Slint is a GUI toolkit, and is largely not relevant to concatenative programming. But the latest release adds a touch of postfix to the mix, which is nice to see.

From the blog post:

Math Gains Postfix Support

A subtle but profound change to the language. Traditional syntax:

Math.max(20, Math.abs(value.x))

New postfix syntax:

value.x.abs().max(20)

The new syntax improves readability by making the transformation steps more explicit. It works well for many operations but has limitations:

Effective for simple transformations (e.g., abs, max) Less intuitive for operations like clamp or atan2.

pos.y.atan2(pos.x) // Less clear than atan2(pos.y, pos.x)

So for now you cannot use postfix for all functions in the Math namespace. We may revisit these cases later, so give them a try and let us know your thoughts.

[–] Andy@programming.dev 6 points 1 year ago (4 children)

I don't know what I should be noticing there. I can't see any text for the tool buttons along the left edge of the window.

[–] Andy@programming.dev 5 points 1 year ago (11 children)

Anyone notice non-obvious Wayland road blocks?

I think the last thing keeping me on X11 is window shade.

[–] Andy@programming.dev 8 points 1 year ago* (last edited 1 year ago) (6 children)

I have trouble with both, but more experience with GIMP. I can't stand all the little tool buttons with no text. I want the name of each tool always visible on its button.

I have the same problem with Inkscape.

[–] Andy@programming.dev 1 points 1 year ago

Difference of Squares

USING: kernel math math.statistics ranges sequences ;

: difference-of-squares ( n -- n' )
  [1..b] [ sum sq ] [ sum-of-squares ] bi - abs ;

[–] Andy@programming.dev 1 points 1 year ago (1 children)

Scrabble Score, 3.5

USING: assocs.extras kernel literals make sequences unicode ;

CONSTANT: charscores $[
  [
    "AEIOULNRST" [  1 swap ,, ] each
            "DG" [  2 swap ,, ] each
          "BCMP" [  3 swap ,, ] each
         "FHVWY" [  4 swap ,, ] each
             "K" [  5 swap ,, ] each
            "JX" [  8 swap ,, ] each
            "QZ" [ 10 swap ,, ] each
  ] H{ } make
]

: scrabble-score ( str -- n )
  charscores swap >upper values-of sum ;

[–] Andy@programming.dev 1 points 1 year ago (2 children)

Scrabble Score, a third time

USING: assocs.extras kernel make sequences unicode ;

: scrabble-score ( str -- n )
  >upper
  [
    "AEIOULNRST" [  1 swap ,, ] each
            "DG" [  2 swap ,, ] each
          "BCMP" [  3 swap ,, ] each
         "FHVWY" [  4 swap ,, ] each
             "K" [  5 swap ,, ] each
            "JX" [  8 swap ,, ] each
            "QZ" [ 10 swap ,, ] each
  ] H{ } make
  swap values-of sum ;

[–] Andy@programming.dev 5 points 1 year ago (2 children)

It's more about replacing typed text than using shortcuts, but there's espanso.

[–] Andy@programming.dev 1 points 1 year ago (3 children)

Scrabble Score, again

USING: combinators kernel sequences sets unicode ;

MEMO: char>score ( char -- n )
  {
    { [ dup "AEIOULNRST" in? ] [  1 ] }
    { [ dup         "DG" in? ] [  2 ] }
    { [ dup       "BCMP" in? ] [  3 ] }
    { [ dup      "FHVWY" in? ] [  4 ] }
    { [ dup          "K" in? ] [  5 ] }
    { [ dup         "JX" in? ] [  8 ] }
    { [ dup         "QZ" in? ] [ 10 ] }
  } cond nip ;

: scrabble-score ( str -- n )
  >upper [ char>score ] map-sum ;

[–] Andy@programming.dev 1 points 1 year ago* (last edited 1 year ago) (4 children)

Scrabble Score

USING: assocs kernel sequences sets unicode ;

MEMO: char>score ( char -- n )
  {
    { 1 "AEIOULNRST" } { 2 "DG" }
    { 3 "BCMP" } { 4 "FHVWY" }
    { 5 "K" } { 8 "JX" } { 10 "QZ" }
  } [ nip dupd in? ] assoc-find 2drop nip ;

: scrabble-score ( str -- n )
  >upper [ char>score ] map-sum ;

[–] Andy@programming.dev 1 points 1 year ago
[–] Andy@programming.dev 7 points 1 year ago (1 children)

Ok next time I won't use your computer.

view more: ‹ prev next ›