Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Uncategorized
  3. Got an exam Wednesday that lumi should study for since it failed that class.

Got an exam Wednesday that lumi should study for since it failed that class.

Scheduled Pinned Locked Moved Uncategorized
2 Posts 2 Posters 4 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • lumiL This user is from outside of this forum
    lumiL This user is from outside of this forum
    lumi
    wrote last edited by
    #1

    Got an exam Wednesday that lumi should study for since it failed that class. Instead, been learning Koka

    // +, 0, - -> 1, 0, -1
    
    fun unfoldr(f : b -> maybe2, init : b) : div list
      match f(init)
        Just2(a, b) -> Cons(a, unfoldr(f, b))
        Nothing2 -> Nil
    
    fun map-if(xs : list, f : a -> a, b : bool) : list
      if b
      then xs.map(f)
      else xs
    
    fun neg-trit(trit : char) : char
      match trit
        '+' -> '-'
        '-' -> '+'
        e -> e
    
    fun bal-tri(x : int) : div list
      unfoldr(fn(n)
        if n != 0
        then match n % 3
          0 -> Just2('0', n / 3)
          1 -> Just2('+', n / 3)
          _ -> Just2('-', n / 3 + 1)
        else Nothing2
      , x.abs).map-if(neg-trit, x.is-neg()).reverse()
    -9.bal-tri().string()
    -00
    25.bal-tri().string()
    +0-+

    M 1 Reply Last reply
    0
    • lumiL lumi

      Got an exam Wednesday that lumi should study for since it failed that class. Instead, been learning Koka

      // +, 0, - -> 1, 0, -1
      
      fun unfoldr(f : b -> maybe2, init : b) : div list
        match f(init)
          Just2(a, b) -> Cons(a, unfoldr(f, b))
          Nothing2 -> Nil
      
      fun map-if(xs : list, f : a -> a, b : bool) : list
        if b
        then xs.map(f)
        else xs
      
      fun neg-trit(trit : char) : char
        match trit
          '+' -> '-'
          '-' -> '+'
          e -> e
      
      fun bal-tri(x : int) : div list
        unfoldr(fn(n)
          if n != 0
          then match n % 3
            0 -> Just2('0', n / 3)
            1 -> Just2('+', n / 3)
            _ -> Just2('-', n / 3 + 1)
          else Nothing2
        , x.abs).map-if(neg-trit, x.is-neg()).reverse()
      -9.bal-tri().string()
      -00
      25.bal-tri().string()
      +0-+

      M This user is from outside of this forum
      M This user is from outside of this forum
      Maifeierlander
      wrote last edited by
      #2

      @lumi study for it smh, you can do it

      1 Reply Last reply
      1
      0
      • R ActivityRelay shared this topic
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      Powered by NodeBB Contributors
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups