多巧啊, 人家姓 Curry 名 Haskell, 难怪 Haskell 语言会自动柯里化, 呵呵. 但是不奇怪吗, 为什么要柯里化呢. 为什么如此重要导致 Haskell 会默认自动柯里化所有函数, 不就是返回一个部分配置好的函数吗.
我们来看一个 Haskell 的代码.
max 3 4
(max 3) 4| /* | |
| * Copyright (C) 2014 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| /** | |
| * Checkstyle tasks | |
| * Usage: | |
| * - place this file under root dir of your project at /gradle directory | |
| * - apply script from your gradle file: | |
| * apply from : "{rootDir}/gradle/checkstyle.gradle" | |
| * | |
| * To configure checkstyle use configs at: | |
| * "{rootDir}/config/checkstyle/checkstyle.xml" - for main projects | |
| * "{rootDir}/config/checkstyle/checkstyle-test.xml" - for tests |
| import com.google.auto.value.AutoValue; | |
| import java.lang.annotation.Retention; | |
| import java.lang.annotation.Target; | |
| import static java.lang.annotation.ElementType.TYPE; | |
| import static java.lang.annotation.RetentionPolicy.RUNTIME; | |
| /** | |
| * Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization. | |
| * <p> |
| import rx.Observable; | |
| import rx.subjects.PublishSubject; | |
| import rx.subjects.SerializedSubject; | |
| import rx.subjects.Subject; | |
| /** | |
| * Simple pass-thru event bus with error handling and reconnect. | |
| */ | |
| public class EventBus { |
| import android.content.Context; | |
| import android.content.res.TypedArray; | |
| import android.graphics.Canvas; | |
| import android.graphics.drawable.Drawable; | |
| import android.util.AttributeSet; | |
| import android.widget.ImageView; | |
| public class ForegroundImageView extends ImageView { | |
| private Drawable foreground; |
| /* | |
| * Copyright (C) 2014 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| public class CircularProgressDrawable extends Drawable | |
| implements Animatable { | |
| private static final Interpolator ANGLE_INTERPOLATOR = new LinearInterpolator(); | |
| private static final Interpolator SWEEP_INTERPOLATOR = new DecelerateInterpolator(); | |
| private static final int ANGLE_ANIMATOR_DURATION = 2000; | |
| private static final int SWEEP_ANIMATOR_DURATION = 600; | |
| private static final int MIN_SWEEP_ANGLE = 30; | |
| private final RectF fBounds = new RectF(); |
| public Bitmap blurBitmap(Bitmap bitmap){ | |
| //Let's create an empty bitmap with the same size of the bitmap we want to blur | |
| Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); | |
| //Instantiate a new Renderscript | |
| RenderScript rs = RenderScript.create(getApplicationContext()); | |
| //Create an Intrinsic Blur Script using the Renderscript | |
| ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); |
| package com.app.video.ui; | |
| import android.content.Context; | |
| import android.os.Build; | |
| import android.view.Gravity; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.WindowManager; | |
| import android.widget.FrameLayout; |