由于我无法chrome.extension.getURL()在CSS文件上使用,如何将@ font-face与本地字体文件一起使用?
任何函数式语言编译器/运行时是否会在应用时将所有链式迭代减少为一个?从程序员的角度来看,我们可以使用诸如懒惰和流等结构来优化功能代码,但我很想知道故事的另一面.我的功能示例是用Scala编写的,但请不要限制您对该语言的回答.
功能方式:
// I assume the following line of code will go
// through the collection 3 times, one for creating it
// one for filtering it and one for summing it
val sum = (1L to 1000000L).filter(_ % 2 == 0).sum // => 250000500000
Run Code Online (Sandbox Code Playgroud)
我希望编译器优化到命令式等效于:
/* One iteration only */
long sum, i;
for (i = 1L, sum = 0L; i <= 1000000L; i++) {
if (i % 2 == 0)
sum += i;
}
Run Code Online (Sandbox Code Playgroud) optimization functional-programming scala compiler-optimization