标签: repeat

重复的组合

我正在使用Mathematica 7和一个combinatorica包函数我可以从一个元素列表获得一定数量的所有组合,其中顺序无关紧要且没有重复.eg:

in: KSubsets[{a, b, c, d}, 3]
out: {{a, b, c}, {a, b, d}, {a, c, d}, {b, c, d}}
Run Code Online (Sandbox Code Playgroud)

我无法找到一个功能,这将使我一定数目的所有组合从元素,其中的顺序并不重要,那里的名单重复的.即,上面的示例将在输出中包含{a,a,b},{a,a,a},{b,b,b}等元素.

它可能需要自定义功能.如果我能拿出一个,我会发一个答案但是现在我没有看到明显的解决方案.

编辑:理想情况下,输出将不包含组合的重复,例如元组[{a,b,c,d},3]将返回包含两个元素的列表,如{a,a,b}和{b,a,a从组合的角度来看,它们是相同的.

combinations wolfram-mathematica repeat

8
推荐指数
3
解决办法
4901
查看次数

Matlab - 通过多次合并相同的原始矢量来构建矩阵

是否有matlab功能允许我进行以下操作?

x = [1 2 2 3];

然后基于x我想构建矩阵m = [1 2 2 3; 1 2 2 3; 1 2 2 3; 1 2 2 3]

matlab tiling rows matrix repeat

8
推荐指数
1
解决办法
1万
查看次数

所有使用scala重复的排列

我正在寻找scala方式来给出所有排列而不重复.我知道这个网站上已有一些帖子,但它们似乎有一个稍微不同的问题.

我正在寻找重复的所有排列.例如:

combine(List('A','C','G'))
Run Code Online (Sandbox Code Playgroud)

应该产量:

List(List('A'.'A','A'),List('A'.'A','C'),List('A'.'A','G'),List('A'.'C','A'),
List('A'.'C',''C), ... List('G'.'G','G')
Run Code Online (Sandbox Code Playgroud)

如果我的问题已经解决但我无法找到,我很抱歉.

提前致谢.

编辑:

我自己的方法(不编译):

def combine(size: Int = sym.length) : List[List[T]] = {
  size match {
    case 0 => List()
    case 1 => sym.toList.map(List(_))
    case _ => for (el <- sym) yield el :: combine(size-1)
  }
}
Run Code Online (Sandbox Code Playgroud)

sym是一个类的数组成员,它包含要组合的所有符号.

combinations scala combinatorics repeat

8
推荐指数
3
解决办法
8484
查看次数

使用animateKeyframesWithDuration在屏幕上创建一个连续旋转的方块

我尝试使用下面的代码在屏幕上创建一个连续旋转的方块.但我不知道为什么转速在变化.如何更改代码以使旋转速度不变?我尝试了不同UIViewKeyframeAnimationOptions,但似乎没有一个工作.

override func viewDidLoad() {
    super.viewDidLoad()

    let square = UIView()
    square.frame = CGRect(x: 55, y: 300, width: 40, height: 40)
    square.backgroundColor = UIColor.redColor()
    self.view.addSubview(square)

    let duration = 1.0
    let delay = 0.0
    let options = UIViewKeyframeAnimationOptions.Repeat
        UIView.animateKeyframesWithDuration(duration, delay: delay, options: options, animations: {
        let fullRotation = CGFloat(M_PI * 2)

        UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 1/3, animations: {
            square.transform = CGAffineTransformMakeRotation(1/3 * fullRotation)
        })                        
        UIView.addKeyframeWithRelativeStartTime(1/3, relativeDuration: 1/3, animations: {
            square.transform = CGAffineTransformMakeRotation(2/3 * fullRotation)
        })                        
        UIView.addKeyframeWithRelativeStartTime(2/3, relativeDuration: 1/3, animations: {
            square.transform = …
Run Code Online (Sandbox Code Playgroud)

animation rotation repeat ios swift

8
推荐指数
2
解决办法
3190
查看次数

UserNotification在3天后重复每天/每小时 - iOS 10

UILocalNotification已被折旧,因此我想将我的代码更新为UserNotification框架:

let alertDays = 3.0
let alertSeconds = alertDays * 24.0 * 60.0 * 60.0

let localNotification:UILocalNotification = UILocalNotification()

localNotification.alertAction = "Reminder"
localNotification.alertTitle = "Reminder Title"
localNotification.alertBody = "Reminder Message"
localNotification.fireDate = Foundation.Date(timeIntervalSinceNow: alertSeconds)
localNotification.repeatInterval = .day            
UIApplication.shared().scheduleLocalNotification(localNotification)
Run Code Online (Sandbox Code Playgroud)

在等待初始通知后,如何使用UserNotification框架设置类似的每日或每小时重复?

let alertDays = 3.0
let alertSeconds = alertDays * 24.0 * 60.0 * 60.0

let content: UNMutableNotificationContent = UNMutableNotificationContent()

content.title = "Reminder Title"
content.subtitle = "Reminder Subtitle"
content.body = "Reminder Message"

let calendar = Calendar.current

let alarmTime = Foundation.Date(timeIntervalSinceNow: alertSeconds)
let …
Run Code Online (Sandbox Code Playgroud)

notifications date repeat swift ios10

8
推荐指数
1
解决办法
3174
查看次数

位图重复+圆角

我试图创建圆角矩形和背景作为重复位图.我这样写,但是在角落里得到位图.

任何人都可以帮忙吗?

background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <shape>
        <stroke
            android:width="1dp"
            android:color="#FFFFFF" />

        <corners android:radius="50dp" />
    </shape>
</item>
<item>
    <bitmap
        android:src="@drawable/carbon_4"
        android:tileMode="repeat" />
</item>

</layer-list>
Run Code Online (Sandbox Code Playgroud)

android background bitmap repeat rounded-corners

7
推荐指数
2
解决办法
3366
查看次数

快速精确的Python重复计时器

我需要快速准确地从列表中发送重复消息.一个列表需要每100ms发送一次消息,窗口为+/- 10ms.我尝试使用下面的代码,但问题是计时器等待100毫秒,然后所有计算都需要完成,使计时器落在可接受的窗口之外.

简单地减少等待是一个混乱,不可靠的黑客.如果在循环期间编辑列表,则消息循环周围会有一个Lock.

关于如何让python在100ms左右发送消息的想法?谢谢

from threading import Timer
from threading import Lock

class RepeatingTimer(object):
    def __init__(self,interval, function, *args, **kwargs):
        super(RepeatingTimer, self).__init__()
        self.args = args
        self.kwargs = kwargs
        self.function = function
        self.interval = interval
        self.start()

    def start(self):
        self.callback()

    def stop(self):
        self.interval = False

    def callback(self):
        if self.interval:
            self.function(*self.args, **self.kwargs)
            Timer(self.interval, self.callback, ).start()

def loop(messageList):
    listLock.acquire()
    for m in messageList:
        writeFunction(m)
    listLock.release()


MESSAGE_LIST = [] #Imagine this is populated with the messages
listLock = Lock()
rt = RepeatingTimer(0.1,loop,MESSAGE_LIST)
#Do other stuff after …
Run Code Online (Sandbox Code Playgroud)

python multithreading timer repeat

7
推荐指数
2
解决办法
1万
查看次数

Matlab:按顺序重复每一列n次

我几乎是初学者,所以很可能以简单的方式做我想做的事.我有一个矩阵121x62,但我需要将它扩展到121x1488所以每列必须重复24次.例如,转换为:

   2.2668       2.2667       2.2667       2.2666       2.2666       2.2666       
   2.2582       2.2582       2.2582       2.2582       2.2581       2.2581       
    2.283        2.283        2.283       2.2829       2.2829       2.2829       
   2.2881       2.2881       2.2881       2.2881       2.2881        2.288        
    2.268        2.268       2.2679       2.2679       2.2678       2.2678       
   2.2742       2.2742       2.2741       2.2741       2.2741        2.274    
Run Code Online (Sandbox Code Playgroud)

进入这个:

2.2668     2.2668     2.2668  and so on to 24th     2.2667     2.2667  and again to 24x
2.2582     2.2582     2.2582 ...
Run Code Online (Sandbox Code Playgroud)

每一列.

我试图用这些值创建一个向量,然后用vec2mat转换,好吧我有121x1488矩阵但是按行重复:

2.2668   2.2668   2.2668  2.2668  2.2668  2.2668 ...    2.2582   2.2582  2.2582  2.2582 ...
Run Code Online (Sandbox Code Playgroud)

怎么做列?

matlab matrix repeat

7
推荐指数
2
解决办法
1万
查看次数

重复动画角4

我创建了以下动画:

fade.animation.ts:

import { Component } from '@angular/core';
import { trigger, state, animate, query, transition, style, stagger } from 
'@angular/animations';
export let fade = trigger('fade', [
   state('void', style({ opacity: 0 })),
   transition(':enter, :leave', [
    animate(2000)
   ])
]);
Run Code Online (Sandbox Code Playgroud)

我正在使用下一个组件:

 <div id="mpl_loader" class="divCabeceraTitulo">
        <div class="lineaTitulo">
            <div class="logoMinisterio" [@fade]>
                <img src="assets/imagenes/SRDLOGO.png">
            </div> 
            <div class="logoGesRepro">
               <img  class="imgGesRepro" src="assets/imagenes/gesReproB.png">
            </div>           
            <div class="descripcionAplicacion">
                <span>título</span>
            </div>
        </div>
  </div>
Run Code Online (Sandbox Code Playgroud)

动画工作,问题是它只运行一次,当它加载组件时,我想要的是它"n"次.我怎么了?请帮忙

animation repeat angular angular-animations

7
推荐指数
1
解决办法
5001
查看次数

Rust 宏:根据参数数量重复 n 次,而不使用实际参数

是否可以根据参数数量重复某件事 n 次而不使用实际参数?我的用例是实现一个Enum变体,它需要 1 个或多个类型参数以及使用通配符匹配枚举变体的实现。因此通配符的数量将取决于提供的参数的数量。例子:

macro_rules! impl_enum {
    ($name: ident, $($params: ty)+, $val:expr) => {
        enum MyEnum {
            $name($($params)+,)
        }
        impl MyEnum {
            fn get_val(self) {
                match self {
                    MyEnum::$name(??????) => $val
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

现在我想要的输出

impl_enum!(Variant1, Type1 Type2 Type3, 42);
Run Code Online (Sandbox Code Playgroud)

成为

            enum MyEnum {
                Variant1(Type1, Type2, Type3),
            }
            impl MyEnum {
                fn get_val(self) {
                    match self {
                        MyEnum::Variant1(_,_,_) => 42,
                    }
                }
            }
Run Code Online (Sandbox Code Playgroud)

这可能吗?

macros repeat rust

7
推荐指数
1
解决办法
2178
查看次数