• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ramda.times函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ramda.times函数的典型用法代码示例。如果您正苦于以下问题:TypeScript times函数的具体用法?TypeScript times怎么用?TypeScript times使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了times函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

    it('should assert many', () => {
        const n = 50000;
        const unsorted = R.times(() => Math.floor(Math.random() * (n - 1 + 1) + 1), n);

        const sorted = sort(unsorted);
        let ramdaSorted = R.sort(R.subtract, unsorted);

        expect(sorted).toEqual(ramdaSorted);
    });
开发者ID:sprengerjo,项目名称:katas_js,代码行数:9,代码来源:test_sort.spec.ts


示例2: filter

 ...map(word => {
   const wordObj = this.createWord(word);
   const wordLetters = (wordObj ? wordObj.toString() : word).split('');
   const numberOfOptions: number = 3;
   const numberMissing: number =
     this.props.difficulty < 0.2
       ? 1
       : this.props.difficulty < 0.4
       ? 2
       : this.props.difficulty < 0.6
       ? 3
       : this.props.difficulty < 0.8
       ? 4
       : wordLetters.length;
   const knownLettersInWord = filter(
     i => indexOf(wordLetters[i].toLowerCase(), this.letters) !== -1,
     times(identity, wordLetters.length)
   );
   const missing = sample(knownLettersInWord, numberMissing);
   const options = map(missingLetterIndex => {
     const opt = sample(
       [
         ...sample(
           without(
             [wordLetters[missingLetterIndex].toLowerCase()],
             this.letters
           ),
           numberOfOptions - 1
         ),
         wordLetters[missingLetterIndex]
       ],
       numberOfOptions
     );
     return wordLetters[missingLetterIndex] ===
       wordLetters[missingLetterIndex].toLowerCase()
       ? map(s => s.toLowerCase(), opt)
       : map(capitalizeFirstLetter, opt);
   }, missing);
   return this.createExercise(ExerciseTypes.MissingText, {
     type: 'MissingText',
     word,
     text: wordLetters,
     missing,
     options
   });
 }, words)
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:46,代码来源:missing-letter.ts


示例3: generateExercises

  protected generateExercises() {
    const numberOfLetters = this.props.difficulty < 0.2 ? 3 : 5;
    const numberOfRotated = this.props.difficulty < 0.5 ? 1 : 2;
    const letters: string[] = sample(this.letters, numberOfLetters);
    const rotated: number[] = sample(
      times(identity, numberOfLetters),
      numberOfRotated
    );
    const angles: string[] = map(() => {
      const sign = [-1, 1][getRandomInt(0, 1)];
      const angle = getRandomInt(3, 15) * 10 * sign;
      return `${angle}deg`;
    }, rotated);

    const version = sample(['a', 'b'], 1);
    const text: string =
      numberOfRotated > 1
        ? 'Welche Buchstaben sind gedreht?'
        : 'Welcher Buchstabe ist gedreht';
    const sound: string =
      numberOfRotated > 1
        ? `exercises_welche_buchstaben_sind_gedreht_${version}`
        : `exercises_welcher_buchstabe_ist_gedreht_${version}`;

    return [
      this.createExercise(ExerciseTypes.InfoScreenWithSounds, {
        type: 'ExplanationText',
        text,
        sound
      }),
      this.createExercise(ExerciseTypes.InfoScreen, {
        type: 'TutorialVideo',
        video: 'explanation_letter_rotated'
      }),
      this.createExercise(ExerciseTypes.LetterRotated, {
        type: 'LetterRotated',
        letters,
        rotated,
        angles,
        difficulty: this.props.difficulty
      })
    ];
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:43,代码来源:letter-rotated.ts


示例4: map

        map(word => {
          const wordObj = this.createWord(word);
          if (!wordObj) {
            return undefined;
          }
          const syllablesRawString = wordObj.getRawSingular();
          if (!syllablesRawString || syllablesRawString.indexOf('|') === -1) {
            return undefined;
          }
          const syllables = syllablesRawString.replace(/['-]/g, '').split('|');

          const missingSyllableIndices = sample(
            times(identity, syllables.length),
            1
          );
          try {
            const options = map(missingSyllableIndex => {
              const syllableOptions = this.createOptionsForSyllable(
                syllables[missingSyllableIndex]
              );
              if (!syllableOptions) {
                throw new Error(
                  `ConnectSyllables: Options empty at word ${syllablesRawString}, syllable ${missingSyllableIndex}`
                );
              }
              return syllableOptions;
            }, missingSyllableIndices);

            return this.createExercise(ExerciseTypes.MissingText, {
              type: 'MissingText',
              word,
              text: syllables,
              missing: missingSyllableIndices,
              options
            });
          } catch (err) {
            Sentry.captureException(err);
            return undefined;
          }
        }, words)
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:40,代码来源:connect-syllables.ts


示例5: it

 it('perfect games score is 300', () => {
   const rolls = times(always(10), 12);
   expect(score(rolls)).toEqual(300)
 });
开发者ID:sprengerjo,项目名称:katas_js,代码行数:4,代码来源:bowling_score_calculator.spec.ts


示例6: generateBookmarkInfo

export const generateBookmarkTree = () => ({
  children: R.times(() => generateBookmarkInfo(), 20),
  parent: generateBookmarkInfo(CST.BOOKMARK_TYPES.FOLDER)
})
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:4,代码来源:bookmarkTrees.ts



注:本文中的ramda.times函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.trim函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.tap函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap