Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HASKELL
- funkcja :: (Float, Float, Float) -> [Float]
- funkcja (a, b, c) = if zmienna1==zmienna2 then [zmienna1] else if zmiennaDelta < 0 then [] else [zmienna1,zmienna2] where
- zmienna1 = d + sqrt zmiennaDelta / (2 * a)
- zmienna2 = d - sqrt zmiennaDelta / (2 * a)
- zmiennaDelta = b * b - 4 * a * c
- d = - b / (2 * a)
- JAVASCRIPT
- class proces{
- constructor(id,takt,pryioryter){
- this.id = id
- this.takt = takt
- if(pryioryter<0 || pryioryter>10){
- throw "zły pryiorytet"
- }
- else{
- this.pryioryter=pryioryter
- }
- }
- }
- function comparator(a,b){
- if (a.pryioryter > b.pryioryter) {
- return -1;
- } else {
- return 1;
- }
- }
- class app{
- consturctor(){
- this.process = new Array()
- proces = new proces(1,0,0);
- this.process.push(proces)
- }
- add(proces){
- this.process.push(proces)
- }
- deleteByID(id){
- for(let i =0;i<this.process.length;i++){
- if(this.process[i].id == id){
- this.process.splice(i, 1);
- }
- }
- }
- sortuj(){
- this.process.sort(comparator()) // w teorii sortuje po pryiorytecie
- }
- }
- let x = new app()
- x.add(new proces(1,10,4))
- x.add(new proces(2,11,5))
- var manager={
- apps: [x,new app()],
- add(app){
- apps.push(app)
- },
- addProcesToApp(proces){
- if(proces.pryioryter == 0){ // REAL TIME PROCES
- while(proces.takt != 1){
- proces.takt--
- }
- }
- apps[0].push(proces)
- },
- deleteApp(){
- this.apps.splice(0, 1);
- },
- sortuj(){
- //sortuje aplikacje
- },
- update(){ // taka yolo imlementacja
- for(x in apps){
- x.sortuj()
- }
- this.sortuj()
- this.apps[0].process[0].takt--
- if(apps[0].process[0].takt == 1){
- apps[0].process.deleteByID(apps[0].process[0].id)
- }
- if(apps[0].process.length == 0){
- this.deleteApp()
- }
- }
- }
- while(manager.apps.length != 0){
- manager.update
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement