36 Matching Annotations
  1. Dec 2023
  2. Jun 2023
  3. May 2023
  4. Mar 2023
      • Matches by Object property ```js const { matches } = require('z')

      const person = { name: 'Maria' } matches(person)( (x = { name: 'John' }) => console.log('John you are not welcome!'), (x) => console.log(Hey ${x.name}, you are welcome!) ) - Matches by type or instancesjs const { matches } = require('z')

      const result = matches(1)( (x = 2) => 'number 2 is the best!!!', (x = Number) => number ${x} is not that good, (x = Date) => 'blaa.. dates are awful!' )

      console.log(result) // output: number 1 is not that good - Matches Array contentjs const { matches } = require('z')

      matches([1, 2, 3, 4, 5])( (a, b, c, tail) => 'a = 1, b = 2, c = 3, tail = [4, 5]'<br /> )

      matches([1, 2])( (a, tail) => 'a = 1, tail = [2]'<br /> )

      matches([1])( (a, b, tail) => 'Will not match here', (a = 2, tail = []) => 'Will not match here', (a = 1, tail) => 'Will match here, tail = []' ) ```

      • Powerful recursive code which will remove sequential repeated items from Array ```js const { matches } = require('z')

      const compress = (numbers) => { return matches(numbers)( (x, y, xs) => x === y ? compress([x].concat(xs)) : [x].concat(compress([y].concat(xs))), (x, xs) => x // stopping condition ) }

      compress([1, 1, 2, 3, 4, 4, 4]) //output: [1, 2, 3, 4] ```

    1. js match (res) { if (isEmpty(res)) { … } when ({ pages, data }) if (pages > 1) { … } when ({ pages, data }) if (pages === 1) { … } else { … } }


      js match (arithmeticStr) { when (/(?<left>\d+) \+ (?<right>\d+)/) as ({ groups: { left, right } }) { process(left, right); } when (/(?<left>\d+) \+ (?<right>\d+)/) { process(left, right); } // maybe? else { ... } }


      ```js class Name { static Symbol.matcher { const pieces = matchable.split(' '); if (pieces.length === 2) { return { matched: true, value: pieces }; } } }

      match ('Tab Atkins-Bittner') { when (^Name with [first, last]) if (last.includes('-')) { … } when (^Name with [first, last]) { … } else { ... } } ```


      js const res = await fetch(jsonService) match (res) { when ({ status: 200, headers: { 'Content-Length': s } }) { console.log(`size is ${s}`); } when ({ status: 404 }) { console.log('JSON not found'); } when ({ status }) if (status >= 400) { throw new RequestError(res); } };


      ```js function todoApp(state = initialState, action) { return match (action) { when ({ type: 'set-visibility-filter', payload: visFilter }) { ({ ...state, visFilter }); } when ({ type: 'add-todo', payload: text }) { ({ ...state, todos: [...state.todos, { text, completed: false }] }); } when ({ type: 'toggle-todo', payload: index }) { const newTodos = state.todos.map((todo, i) => { return i !== index ? todo : { ...todo, completed: !todo.completed }; });

        ({
          ...state,
          todos: newTodos,
        });
      }
      else { state } // ignore unknown actions
      

      } } ```


      jsx <Fetch url={API_URL}> {props => match (props) { when ({ loading }) { <Loading />; } when ({ error }) { <Error error={error} />; } when ({ data }) { <Page data={data} />; } }} </Fetch>

  5. Jan 2023
    1. WHERE HORSE.OWNER_ID = OWNER.OWNER_ID;

      Where clauses can be used to specify join matching logic. A where clause can be used to indicate that a column in table A is equal to a column in table B, and that equivilancy can be used to join table A rows to table B rows. THe format is as simple as

      TableA.MatchingColumn = TableB.MatchingColumn

  6. Dec 2022
  7. Sep 2022
  8. Jul 2022
  9. bafybeibbaxootewsjtggkv7vpuu5yluatzsk6l7x5yzmko6rivxzh6qna4.ipfs.dweb.link bafybeibbaxootewsjtggkv7vpuu5yluatzsk6l7x5yzmko6rivxzh6qna4.ipfs.dweb.link
    1. boredom, as it does not fully engage the attention, while a too difficult one produces anxiety, as theperson becomes afraid to fail. Only a task that is challenging enough will engender the level ofintense, but tranquil, concentration that characterizes flow. There are two ways to control thebalance between challenges and skills: changing the intrinsic difficulty of the task, and changing theperson’s ability to cope with the task. At first sight, balance could be achieved by proposing arelatively easy task at which the person is not particularly skilled. But a more advanced model seesflow as emerging from high skills applied to difficult challenges (Fig. 1). In this more complexmodel (Nakamura & Csikszentmihalyi, 2002), limited skills applied to limited challenges merelyproduce apathy, as there is not much to create interest.This means that a good mobilization system not only should present goals that are difficultto reach, but provide the additional abilities necessary to handle that difficulty. This is the “newskills” feature that characterizes a truly compelling technology: you will feel most stimulated to usea tool if it allows you to tackle challenges that you could not tackle without it—albeit in such a waythat its use is fully intuitive and transparent. Eventually, a good tool should start to feel like anaugmentation or extension of yourself—the way a stick extends the reach of your arm, a telescopeextends your vision, and a notebook extends your memory.

      Balance between difficulty of task and level of skills Task that is too easy produces boredom, too difficult produces anxiety. Flow state exists when the difficulty is balanced with the skill level.

      New technologies and processes are new tools that are exciting to learn because they allow us to engage old problems in novel new ways. When we innovate and solve problems using novel techniques, it increases our level of engagement and satisfaction.

  10. May 2022
  11. Mar 2022
    1. The URLPattern API provides a web platform primitive for matching URLs based on a convenient pattern syntax.
  12. Aug 2021
    1. # And standalone like a case:Qo.match(people.first, Qo.m(age: 10..19) { |person| "#{person.name} is a teen that's #{person.age} years old" }, Qo.m(:*) { |person| "#{person.name} is #{person.age} years old" })
    2. # How about some "right-hand assignment" pattern matchingname_longer_than_three = -> person { person.name.size > 3 }people_with_truncated_names = people.map(&Qo.match_fn( Qo.m(name_longer_than_three) { |person| Person.new(person.name[0..2], person.age) }, Qo.m(:*) # Identity function, catch-all))
  13. Jul 2021
    1. In the examples above, the number 42 on the left hand side isn’t a variable that is being assigned. It is a value to check that the same element in that particular index matches that of the right hand side.
  14. Jun 2020
  15. Jan 2020
  16. Mar 2019
    1. Roth, now 67, gravitated to matching markets, where parties must choose one another, through applications, courtship and other means. In 1995, he wrote a mathematical algorithm that greatly improved the efficiency of the system for matching medical school graduates to hospitals for their residencies. That work led him to improve the matching models for law clerkships, the hiring of newly minted economists, Internet auctions and sororities. “I’m a market designer,” he says. “Currently, I’m focused on kidneys. We’re trying to match more donor kidneys to people globally.”

      Interesting for many, many fields.