Skip Navigation

Posts
187
Comments
356
Joined
2 yr. ago

Concatenative Programming @programming.dev

Konilo: a small, pragmatic personal computing system written in Forth and running on a tiny virtual computer

commandline @programming.dev

xmq: Convert xml/html to a more human readable/editable format (xmq/htmq) and back. Can also work with JSON.

Concatenative Programming @programming.dev

Check out Claro's pipeline syntax

Concatenative Programming @programming.dev

Tacit Programming | discussion on Hacker News

zsh @programming.dev

Using broot as an fzf-like path completer and interactive folder jumper in Zsh

Shell Scripting @programming.dev

Using broot as an fzf-like path completer and interactive folder jumper in Zsh

Concatenative Programming @programming.dev

Reverse Vowels | Re: Factor

Concatenative Programming @programming.dev

Dragonbox | Re: Factor

Concatenative Programming @programming.dev

Divmods | Re: Factor

Concatenative Programming @programming.dev

The Theory of Concatenative Combinators (2002, 2007)

Concatenative Programming @programming.dev

Crontab | Re: Factor

Concatenative Programming @programming.dev

Codewars | Re: Factor (0.99 now supported!)

Concatenative Programming @programming.dev

Stem: an interpreted concatenative language with a foreign language interface

  • That’s true, but if the transformations have more than one argument, they go after the name

    Yup, I understand. That's why I've not put them in the concatenative section.

    Also, there are more languages with this feature, for example D, VimScript or Koka.

    Thanks, maybe I'll add them to the sidebar! I hadn't heard of Koka.

    If you have a suggested heading/description to replace "partially concatenative" I'm interested. Function chaining? And I'm not sure but maybe execline is actually concatenative and needs to be moved out of that section.

  • Exactly. That's the second link under "Wikipedia Topics" in the sidebar.

  • I may be expressing it poorly and inaccurately, but what I mean is that in Nim you can re-order arguments and functions to start with some data followed by a series of transformations. The following two lines are equivalent:

     nim
        
    parse_int(read_line(stdin))
    stdin.read_line().parse_int()
    
      

    Roc offers a similar flow with their |> operator. Here's a snippet from one of my Advent of Code 2022 solutions:

     roc
        
    partOne =
        "input.txt"
        |> getData
        |> Task.await \data ->
            data
            |> getRangePairs
            |> List.keepIf pairHasStrictSubset
            |> List.len
            |> Num.toStr
            |> Stdout.line
    
      
  • Factor!

    It's incredible and elegant and defies some common categorization.

    I've put some of my favorite resources in the sidebar of https://programming.dev/c/concatenative and I'm happy to walk through any particular challenges/examples -- I've done about the first week of Advent of Code with it this year, and the most recent handful of Perl Weekly Challenges, and some basic Euler problems.

  • Plasma may not ever implement window shading for Wayland, but I'm hopeful. That's probably my last blocker.

  • Concatenative Programming @programming.dev

    Marten: Graphical Programming for MacOSX (Prograph)

    Concatenative Programming @programming.dev

    Pipelined Relational Query Language (PRQL, pronounced "Prequel")

  • Examples from the slides, but in Factor:

     factor
        
    USING: kernel math ;
    IN: pipeline-demo.calc
    
    : add1 ( x -- x' ) 1 + ;
    : square ( x -- x' ) dup * ;
    : double ( x -- x' ) 2 * ;
    
    : demo1 ( -- n )
      5
      add1
      square
      double
    ;
    
    : add ( x y -- n ) + ;
    : times ( x y -- n ) * ;
    
    : demo2 ( -- n )
      5
      1 add
      2 times
    ;
    
      
     factor
        
    USING: math sequences sequences.extras ;
    IN: pipeline-demo.collection
    
    : pipeline ( seq -- n )
      [ 2 + ]
      [ 3 > ] map-filter
      length
    ;
    
      
     factor
        
    USING: io kernel math.functions math.parser ranges sequences ;
    IN: pipeline-demo.fizzbuzz
    
    : (fizz-buzz) ( i -- str )
      dup [ 3 divisor? ] [ 5 divisor? ] bi
      2dup or [
        [ "Fizz" "" ? ] [ "Buzz" "" ? ] bi*
        append
        nip
      ] [ 2drop number>string ] if
    ;
    
    : fizz-buzz ( -- )
      35 [1..b]
      [ (fizz-buzz) ] map
      "," join
      print
    ;
    
      
     factor
        
    USING: accessors kernel math strings ;
    IN: pipeline-demo.person
    
    TUPLE: Person
      { Name string read-only }
      { Email string read-only }
      { Age integer read-only }
    ;
    
    : person-with-name ( person name -- person' )
      swap [ Email>> ] [ Age>> ] bi Person boa
    ;
    
    : person-with-email ( person email -- person' )
      swap [ Name>> ] [ Age>> ] bi swapd Person boa
    ;
    
    : person-with-age ( person age -- person' )
      swap [ Name>> ] [ Email>> ] bi rot Person boa
    ;
    
    : demo ( -- person )
      "Scott" "s@example.com" 21 Person boa
      "Tom" person-with-name
      "tom@example.com" person-with-email
      42 person-with-age
    ;
    
      
     factor
        
    USING: sequences splitting strings ;
    IN: pipeline-demo.roman
    
    : >roman-numerals ( n -- str )
      CHAR: I 
      "IIIII" "V" replace
      "VV" "X" replace
      "XXXXX" "L" replace
      "LL" "C" replace
      ! special cases:
      "VIIII" "IX" replace
      "IIII" "IV" replace
      "LXXXX" "XC" replace
      "XXXX" "XL" replace
    ;
    
    : >roman-numerals-alt ( n -- str )
      CHAR: I 
      {
        { "IIIII" "V" }
        { "VV" "X" }
        { "XXXXX" "L" }
        { "LL" "C" }
        ! special cases:
        { "VIIII" "IX" }
        { "IIII" "IV" }
        { "LXXXX" "XC" }
        { "XXXX" "XL" }
      } [ first2 replace ] each
    ;
    
      
  • Concatenative Programming @programming.dev

    Pipeline-oriented programming - Scott Wlaschin - NDC Porto 2023 (F#)

    Concatenative Programming @programming.dev

    The Perl Weekly Challenge is a great source of practice problems

  • wish I cluld have just the folders

    You can copy or symlink folders around between themes in ~/.local/share/icons/.

  • From this thread I tried out Gruvbox Plus Dark, which is nice, but a little low on contrast, and I don't prefer such uniform shapes.

    Huh, I only now notice that the Fluent, Tela, Vimix, and Qogir repos are owned by the same user...

  • Nice to see highlight there, an excellent project with an active and responsive developer. I use it every day in my Zsh aliases and functions, and it's a much faster shell highlighter than bat (or rich-cli), with better language support as well.

  • I don't think apk would check multiple files for the world. But you could maintain them outside the apk mechanisms, just concatenating them into a single file, with tup/make/sh/whatever.

  • FWIW, Alpine Linux has a nice world file, too. And I am continually impressed by the selection of up to date packages in their Edge repos.

  • Any thoughts on the alternative I mentioned, DYN, described here?

  • Approval voting simplifies things but also has limitations because it removes any weight/preference people may have.

    Yes, but nowhere near the problems of IRV. If those particular limitations bother you, as I said:

    If you want to take on a little complexity for some further improvement, use delegable yes/no voting.

    . . . don’t let the perfect be the enemy of the good.

    I see zero "good" in IRV, for all the reasons outlined in the rant. Its failures are absurd and beyond unacceptable given that there are strictly better and simpler alternatives. Don't let something shiny and terrible stop you from using something actually quite good.

  • I'm repeating myself here because a lot of commenters have a misplaced hope for IRV improving things:

    Instant runoff voting is terrible and more complicated than people think, and I will never support it. It's a false improvement whose adoption will discourage meaningful change.

    If it's a single winner election and you want a simple improvement, use approval voting. If you want to take on a little complexity for some further improvement, use delegable yes/no voting. I have one idea for further improvement, if anyone is really interested in voting methods.

    Link to my anti-IRV rant

  • Only responding to the IRV portion of your comment, and repeating myself from elsewhere in this thread:

    Instant runoff voting is terrible and more complicated than people think, and I will never support it. It's a false improvement whose adoption will discourage meaningful change.

    If it's a single winner election and you want a simple improvement, use approval voting. If you want to take on a little complexity for some further improvement, use delegable yes/no voting. I have one idea for further improvement, if anyone is really interested in voting methods.

    Link to my anti-IRV rant

  • Instant runoff voting is terrible and more complicated than people think, and I will never support it. It's a false improvement whose adoption will discourage meaningful change.

    If it's a single winner election and you want a simple improvement, use approval voting. If you want to take on a little complexity for some further improvement, use delegable yes/no voting. I have one idea for further improvement, if anyone is really interested in voting methods.

    Link to my anti-IRV rant

  • In 2020 I paid a one time fee for a lifetime of Pro. Is that definitely not still an option?

  • Concatenative Programming @programming.dev

    Building Hangman | Re: Factor

  • Haha it's all good, but it sounds like selling the house to avoid cleaning a table.

  • Honestly that sounds good to me, but not everyone configures their own preferred fonts, so it may not be a crowd pleaser. It's not too bad for me to just override the style on my side.

  • I had a look and it can be set by setting font-family inside the .hljs block within the theme (e.g. atom-one-dark.css).

  • Concatenative Programming @programming.dev

    FXYT: A tiny, stack-based, postfix canvas colouring language with 36 commands

    Concatenative Programming @programming.dev

    A Forth Vocabulary for Iteration