Skip Navigation
Posts
125
Comments
353
Joined
2 yr. ago
Concatenative Programming @programming.dev

GitHub - BlagojeBlagojevic/blang: Fort [sic?] like lang

Concatenative Programming @programming.dev
github.com Release 0.0.0-alpha1 · roc-lang/roc

We're starting with a new release approach, these files will stay available permanently in contrast to the latest nightly. We now recommend most users to stick to 0.0.0-alpha releases instead of ni...

Release 0.0.0-alpha1 · roc-lang/roc

Copied from the release notes:

We're starting with a new release approach, these files will stay available permanently in contrast to the latest nightly.

We now recommend most users to stick to 0.0.0-alpha releases instead of nightly-latest.

This current release is based on commit a089cf2 from the 6th of January 2025. These files are identical to nightly-latest published on the 7th of January 2025.


EDIT: A whole lot more detail in the new 0.0.0-alpha2-rolling release

  • It's been a while, but my clumsy adding of a comment to the buffer is unnecessary, given zle -M, which will display a message outside of the buffer. So here's an updated version:

     bash
        
    # -- Run input if single line, otherwise insert newline --
    # Key: enter
    # Credit: https://programming.dev/comment/2479198
    .zle_accept-except-multiline () {
      if [[ $BUFFER != *$'\n'* ]] {
        zle .accept-line
        return
      } else {
        zle .self-insert-unmeta
        zle -M 'Use alt+enter to submit this multiline input'
      }
    }
    zle -N       .zle_accept-except-multiline
    bindkey '^M' .zle_accept-except-multiline  # Enter
    
    # -- Run input if multiline, otherwise insert newline --
    # Key: alt+enter
    # Credit: https://programming.dev/comment/2479198
    .zle_accept-only-multiline () {
      if [[ $BUFFER == *$'\n'* ]] {
        zle .accept-line
      } else {
        zle .self-insert-unmeta
      }
    }
    zle -N         .zle_accept-only-multiline
    bindkey '^[^M' .zle_accept-only-multiline  # Enter
    
      
  • Concatenative Programming @programming.dev

    Tacit Talk: a podcast about programming languages, combinators, algorithms and more!

  • The given Uiua example (mercifully given using words rather than the symbols):

     undefined
            [3 4 5 10 23]
        divide length on /+
    
    
      

    For all the talk about "forward" it's uncomfortable to me how the Uiua evaluation within a line happens backward.

    An equivalent in Factor, where keep is close to on:

     undefined
            { 3 4 5 10 23 }
        [ sum ] keep length /
    
    
      

    But this pattern of doing two things in sequence to the same item is common enough that bi is handy:

     undefined
            { 3 4 5 10 23 }
        [ sum ] [ length ] bi /
    
      
  • Concatenative Programming @programming.dev

    Discussion on lobsters

    Concatenative Programming @programming.dev

    Spreadsheets 1/3 - Rye Language

    Concatenative Programming @programming.dev

    ngp/tsk | A filesystem-based task manager

    Concatenative Programming @programming.dev
  • Slow and dumb gets it done! I may revisit this when I give up on future days.

  • Nothing smart to see here. I may revisit this when I give up on future days.

  • Concatenative Programming @programming.dev
    Concatenative Programming @programming.dev
  • Factor

     undefined
        
    : get-input ( -- rules updates )
      "vocab:aoc-2024/05/input.txt" utf8 file-lines
      { "" } split1
      "|" "," [ '[ [ _ split ] map ] ] bi@ bi* ;
    
    : relevant-rules ( rules update -- rules' )
      '[ [ _ in? ] all? ] filter ;
    
    : compliant? ( rules update -- ? )
      [ relevant-rules ] keep-under
      [ [ index* ] with map first2 < ] with all? ;
    
    : middle-number ( update -- n )
      dup length 2 /i nth-of string>number ;
    
    : part1 ( -- n )
      get-input
      [ compliant? ] with
      [ middle-number ] filter-map sum ;
    
    : compare-pages ( rules page1 page2 -- <=> )
      [ 2array relevant-rules ] keep-under
      [ drop +eq+ ] [ first index zero? +gt+ +lt+ ? ] if-empty ;
    
    : correct-update ( rules update -- update' )
      [ swapd compare-pages ] with sort-with ;
    
    : part2 ( -- n )
      get-input dupd
      [ compliant? ] with reject
      [ correct-update middle-number ] with map-sum ;
    
      

    on GitHub

  • Factor

    Better viewed on GitHub.

  • Day 4

    Better viewed on GitHub

  • More Factor solutions for the first 3 days (at time of comment) from okflo, on sourcehut.

  • Have you had a good look at Factor? FWIW I've got at least the first 3 days with it up here.

  • Some more Factor solutions for the first 3 days (so far) from soweli Niko, on Codeberg.

  • Factor

     undefined
        
    : get-input ( -- corrupted-input )
      "vocab:aoc-2024/03/input.txt" utf8 file-contents ;
    
    : get-muls ( corrupted-input -- instructions )
      R/ mul\(\d+,\d+\)/ all-matching-subseqs ;
    
    : process-mul ( instruction -- n )
      R/ \d+/ all-matching-subseqs
      [ string>number ] map-product ;
    
    : solve ( corrupted-input -- n )
      get-muls [ process-mul ] map-sum ;
    
    : part1 ( -- n )
      get-input solve ;
    
    : part2 ( -- n )
      get-input
      R/ don't\(\)(.|\n)*?do\(\)/ split concat
      R/ don't\(\)(.|\n)*/ "" re-replace
      solve ;
    
      
  • Factor

     undefined
        
    : get-input ( -- reports )
      "vocab:aoc-2024/02/input.txt" utf8 file-lines
      [ split-words [ string>number ] map ] map ;
    
    : slanted? ( report -- ? )
      { [ [ > ] monotonic? ] [ [ < ] monotonic? ] } || ;
    
    : gradual? ( report -- ? )
      [ - abs 1 3 between? ] monotonic? ;
    
    : safe? ( report -- ? )
      { [ slanted? ] [ gradual? ] } && ;
    
    : part1 ( -- n )
      get-input [ safe? ] count ;
    
    : fuzzy-reports ( report -- reports )
      dup length <iota> [ remove-nth-of ] with map ;
    
    : tolerable? ( report -- ? )
      { [ safe? ] [ fuzzy-reports [ safe? ] any? ] } || ;
    
    : part2 ( -- n )
      get-input [ tolerable? ] count ;
    
      
  • Factor

     undefined
        
    : get-input ( -- left-list right-list )
      "vocab:aoc-2024/01/input.txt" utf8 file-lines
      [ split-words harvest ] map unzip
      [ [ string>number ] map ] bi@ ;
    
    : part1 ( -- n )
      get-input
      [ sort ] bi@
      [ - abs ] 2map-sum ;
    
    : part2 ( -- n )
      get-input
      histogram
      '[ dup _ at 0 or * ] map-sum ;
    
      

    https://github.com/AndydeCleyre/aoc-2024

  • Day 3

    Image:

  • Day 2:

    Image:

  • Concatenative Programming @programming.dev

    Happy Advent of Code 2024 Everyone!

    Alright, show me I'm not the only one in this community, and show off some solutions!

    Here's my Day 1 solution in Factor (minus imports):

    Sadly, Factor doesn't get highlighted properly here, so here it is again as an image:

    I probably won't last the week, but what solutions I do have will be up on GitHub.

    Concatenative Programming @programming.dev

    This example is my justification for posting it here:

     haskell
        
    "NeoHaskell is cool"
      |> Text.toWordList
      |> List.map Text.length
      |> List.map (\x -> x * x)
      |> List.takeIf Int.isEven
    
      
    Concatenative Programming @programming.dev
    Concatenative Programming @programming.dev

    I posted this project here before, but it's now reached 1.0.0.

    Concatenative Programming @programming.dev
    Concatenative Programming @programming.dev
    Concatenative Programming @programming.dev

    Hey, it includes Factor!

    Python @programming.dev

    What would Enaml 2.0 look like? | nucleic/enaml | Declarative UI

    From Enaml's docs:

    Enaml brings the declarative UI paradigm to Python in a seamlessly integrated fashion. The grammar of the Enaml language is a strict superset of Python. This means that any valid Python file is also a valid Enaml file, though the converse is not necessary true. The tight integration with Python means that the developer feels at home and uses standard Python syntax when expressing how their data models bind to the visual attributes of the UI.

    . . .

    Enaml’s declarative widgets provide a layer of abstraction on top of the widgets of a toolkit rendering library. Enaml ships with a backend based on Qt5/6 and third-party projects such as enaml-web and enaml-native provides alternative backends.


    A maintainer of Enaml has just opened a brainstorm discussion on the next major development goals.

    It's a project I've long admired, though rarely used, and I'd love to see it get some attention

    Concatenative Programming @programming.dev
    Concatenative Programming @programming.dev

    phreda4/r3: r3 programing language - ColorForth inspired

    Concatenative Programming @programming.dev

    Stack Effects (2023) | Re: Factor