Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computation ext #13

Open
phodal opened this issue Nov 5, 2022 · 0 comments
Open

Computation ext #13

phodal opened this issue Nov 5, 2022 · 0 comments

Comments

@phodal
Copy link
Member

phodal commented Nov 5, 2022

Feature Request

Is your feature request related to a problem? Please describe.
add simple math support for fklang

Describe the solution you'd like
like: https://github.com/MetaBorgCube/IceDust

module students

model

  entity Student {
    name       : String
    
    passedCourses : Int = sum(enrollments.pass2)
  }
  
  entity Course {
    name       : String
    
    avgGrade   : Float?  = avg(enrollments.grade)
    passPerc   : Float?  = sum(enrollments.pass2) / count(enrollments) * 100.0
    numStudents: Int     = count(enrollments)
  }
  
  entity Enrollment {
    name       : String  = course.name + " " +student.name
    
    grade      : Float?
    pass       : Boolean = grade >= 5.5 <+ false
    pass2      : Int     = pass ? 1 : 0
  }
  
  relation Course.enrollments *  <-> 1 Enrollment.course
  relation Student.enrollments * <-> 1 Enrollment.student

data

  alice : Student {
    name = "Alice"
  }
  bob : Student {
    name = "Bob"
  }
  charlie : Student {
    name = "Charlie"
  }
  math : Course {
    name = "Math"
    enrollments = 
      enA {
        student = alice
        grade = 8.0
      },
      enB {
        student = bob
        grade = 9.5
      },
      enC {
        student = charlie
        grade = 5.0
      }
  }
  
execute

  math.name
  math.avgGrade
  math.passPerc
  math.numStudents
phodal added a commit that referenced this issue Nov 5, 2022
phodal added a commit that referenced this issue Nov 6, 2022
phodal added a commit that referenced this issue Nov 6, 2022
phodal added a commit that referenced this issue Nov 7, 2022
phodal added a commit that referenced this issue Nov 7, 2022
phodal added a commit that referenced this issue Nov 7, 2022
phodal added a commit that referenced this issue Nov 7, 2022
phodal added a commit that referenced this issue Nov 7, 2022
phodal added a commit that referenced this issue Nov 7, 2022
phodal added a commit that referenced this issue Nov 7, 2022
phodal added a commit that referenced this issue Nov 7, 2022
phodal added a commit that referenced this issue Nov 8, 2022
phodal added a commit that referenced this issue Nov 8, 2022
phodal added a commit that referenced this issue Nov 8, 2022
phodal added a commit that referenced this issue Nov 8, 2022
phodal added a commit that referenced this issue Nov 8, 2022
phodal added a commit that referenced this issue Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant