我想将网站评级列入清单,我该怎么做?

时间:2018-03-18 13:46:59

标签: haskell

userRate :: Film -> Float
userRate (_,_,_,[],[]) = 0
userRate (_,_,_,likes,dislikes) = fromIntegral(length likes)/fromIntegral(length likes + length dislikes)* 100

---圆形用户评分的功能

websiteRating :: Film -> Int
websiteRating film = round(userRate (film)) 

- 函数使用列表推导来过滤网站评级为75及以上的电影

rating:: [Film] -> [Film]
rating films = [ film | film <-films , websiteRating film >=75] 

我创建了一个功能,它给了我一个电影列表,只有那些显示网站评分高于75的电影,但我想在电影旁边添加网站评级

例如,这是显示的内容

Title: Silence
Director: Martin Scorsese
Year:2016
Website Rating : 76



Title: The Terminal
Director: Steven Spielberg
Year:2004
Website Rating : 76%

我想在列表中显示网站评级,我该怎么做? 感谢

1 个答案:

答案 0 :(得分:0)

也许你正在寻找这样的东西,整个结果是一组由电影和评级组成的对。

//*********** IMPORTS *****************
var gulp = require('gulp'),
browserSync = require('browser-sync');
var postcss = require('gulp-postcss');
var less = require('gulp-less');
var watch = require('gulp-watch');
var livereload = require('gulp-livereload');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat-css');
var cssmin = require('gulp-cssmin');


/* BROWSERSYNC */
gulp.task('browserSync', function () {
    var files = ['orient-spa/**'];

    browserSync.init(files, {
       server: {
          baseDir: 'orient-spa/',
          index: 'index.html'
       },
       logPrefix: 'OS01', 
       browser: ['chrome']
    });
});

gulp.task('css', function () {
    var processors = [
        autoprefixer
    ];
    return gulp.src('./orient-spa/skins/less/index-files.less')
    .pipe(less())
    .pipe(postcss(processors))
    .pipe(gulp.dest('./orient-spa/skins/css/'))
    .pipe(livereload());
});

gulp.task('watch', function() {
    livereload.listen();
    gulp.watch('./orient-spa/skins/less/*.less', ['css']);
    gulp.watch('./orient-spa/skins/css/*.css', ['concatMinify']);
});

gulp.task('concatMinify', function () {
    return gulp.src('./orient-spa/skins/css/*.css')
    .pipe(concat("index.css"))
    .pipe(cssmin())
    .pipe(gulp.dest('./orient-spa/skins/css/compiled'))
    .pipe(livereload());
});

gulp.task('default', ['browserSync', 'watch', 'css', 'concatMinify']);