-
Scala도 다른 JVM언어와 마찬가지로 런타임에 타입을 소거
- 컴파일시에는 가능한 타입 정보에 대한 접근이 런타임에는 불가능
-
Scala.reflect.Manifest
,TypeTags
: 컴파일타임에 접근 가능한 타입 정보를 런타임에 전달TypeTag[T]
는 컴파일 타임의 타입T
의 런타임 타입 표현을 캡슐화.TypeTag
는, 2.10 이하 버전에서 사용되었던, 더 많은 기능을 내포한Manifest
의 대안이며, Scala reflection에 통합됨
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait NaturalNumber | |
sealed trait _0 extends NaturalNumber | |
sealed trait _1 extends _0 | |
sealed trait _2 extends _1 | |
sealed trait _3 extends _2 | |
sealed trait _4 extends _3 | |
sealed trait _5 extends _4 | |
sealed trait _6 extends _5 | |
sealed trait _7 extends _6 | |
sealed trait _8 extends _7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
import multiprocessing | |
def q_runner(n_procs, list_item, function, *args): | |
'''generic function used to start worker processes''' | |
task_queue = multiprocessing.Queue() | |
results_queue = multiprocessing.JoinableQueue() | |
if args: | |
arguments = (task_queue, results_queue,) + args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val thumbnails = ArrayList<String>() | |
thumbnails.add("http://www.hotel-r.net/im/hotel/pl/hotel-simple-1.jpg") | |
thumbnails.add("https://media-cdn.tripadvisor.com/media/photo-s/0e/20/6a/59/simple-patagonia-hotel.jpg") | |
thumbnails.add("https://mir-s3-cdn-cf.behance.net/project_modules/disp/65daa813704049.5627720c3ae61.jpg") | |
thumbnails.add("http://www.hotel-r.net/im/hotel/lt/hotel-simple-12.jpg") | |
thumbnails.add("https://images.trvl-media.com/hotels/7000000/6450000/6441600/6441512/6441512_56_z.jpg") | |
thumbnails.add("http://interiii.com/wp-content/uploads/2013/03/Latest-Caro-Hotel-Design-by-Francesc-Rif%C3%A9-Studio-Decoration-Ideas1.jpg") | |
thumbnails.add("https://media-cdn.tripadvisor.com/media/photo-s/05/07/33/ba/smart-and-simple-hotel.jpg") | |
thumbnails.add("https://c1.hiqcdn.com/images/property/resortimg/431680_w85.jpg") | |
thumbnails.add("https://www.cabinn.com/sites/default/files/CabInn_Aalborg_029_0.jpg") |
Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.
- [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
[UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached[UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead[UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.view.Choreographer | |
import io.reactivex.subjects.PublishSubject | |
import java.util.concurrent.TimeUnit | |
object FpsObserver { | |
private val choreographer = Choreographer.getInstance() | |
private val countSubject = PublishSubject.create<Unit>() | |
init { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun guard(predicate: () -> Boolean) : GuardClass { | |
return GuardClass(predicate) | |
} | |
data class GuardClass(val checkFunc: () -> Boolean) { | |
inline infix fun `else`(elseFunc: () -> Nothing) { | |
if (!checkFunc()) { elseFunc() } | |
} | |
} |
Author: Chris Lattner
#Compilng You need g++ 4.9 to compile this code. Follow these steps to install g++-4.9
After installing run the following command to compile
/usr/bin/g++-4.9 -std=c++11 lambda.cpp
#Running
./a.out
- 원문: http://www.nurkiewicz.com/2016/06/functor-and-monad-examples-in-plain-java.html
- 작성자: Tomasz Nurkiewicz
이 글은 우리가 쓴 책, 'Reactive Programming with RxJava' 의 부록이었다. Reactive programming과 관련이 깊은 주제긴 하지만 모나드를 소개한다는 게 책과 썩 어울리지는 않았다. 그래서 나는 따로 블로그에 올리기로 했다. 프로그래밍을 다루는 블로그에서 *"반은 맞고 반은 틀릴 지 모르는 나만의 모나드 설명"*이란 것이 새로운 *"Hello World"*라는 점을 나도 잘 안다. 하지만 이 글은 펑터(functor)와 모나드(monad)를 자바 자료 구조와 라이브러리라는 각도에서 바라보고 있으며, 이는 공유할 정도의 가치는 있을거라 생각했다.
NewerOlder