zoukankan      html  css  js  c++  java
  • 利用JavaScriptCore实现简单的功能(阶乘)

     1 #import "RootViewController.h"
     2 #import <JavaScriptCore/JavaScriptCore.h>
     3 
     4 @interface RootViewController ()
     5 @end
     6 
     7 @implementation RootViewController
     8 
     9 - (void)viewDidLoad {
    10     [super viewDidLoad];
    11     
    12     JSContext *context = [[JSContext alloc] init];
    13     context[@"factorial"] = ^(int x){
    14         int factorial = 1;
    15         for (; x > 1; x--) {
    16             factorial *= x;
    17         }
    18         return factorial;
    19     };
    20     [context evaluateScript:@"var fiveFactorial = factorial(5);"];
    21     JSValue *fiveFactorial = context[@"fiveFactorial"];
    22     NSLog(@"5! = %@",fiveFactorial);
    23     
    24 }
    25 
    26 @end
  • 相关阅读:
    谷歌机器学习
    Pycharm使用conda安装的环境
    HAN模型理解2
    HAN模型理解1
    RCNN
    深度CNN
    多通道CNN
    TextCNN
    词向量2
    词向量1.md
  • 原文地址:https://www.cnblogs.com/lantu1989/p/4650380.html
Copyright © 2011-2022 走看看