Generate the sequence of Fibonacci.
    https://oeis.org/A000045
973987
def fibonacci() -> Iterator[int]:
    
    a, b = 1, 2
    while True:
        yield a
        a, b = b, a + b
339943
def _flatten(n):
    """"""
    if isinstance(n, collections.Sequence):
        for x in n:
            for y in _flatten(x):
                yield y
    else:
        yield n
1127558
private static function _createOracleSequence()
    {
        $name = self::resolveSequenceName();
        $sql  = "create sequence $name increment by 1 start with 1 nocycle nocache";
        Log::log($sql);
        $stmt = self::query($sql);
        self::closeCursor($stmt);
    }
1079404
def chunk_sequence(sequence, chunk_length):
    """"""
    for index in range(0, len(sequence), chunk_length):
        yield sequence[index:index + chunk_length]
175037
def make_sequence(seq, name="S"):
    
    return ["{}_{}_{}".format(name, i, x) for i, x in enumerate(seq)]
1019807
public static short newClockSequence() {
        Random random = new Random();
        byte[] bytes = new byte[BYTES_IN_SHORT];
        random.nextBytes(bytes);
        return (short) (Bytes.toShort(bytes) & 0x3FFF);
    }
1184479
def get_random(self, n, l=None):
        
        random_f = Fasta()
        if l:
            ids = self.ids[:]
            random.shuffle(ids)
            i = 0
            while (i < n) and (len(ids) > 0):
                seq_id = ids.pop()
                if (len(self[seq_id]) >= l):
                    start = random.randint(0, len(self[seq_id]) - l)
                    random_f["random%s" % (i + 1)] = self[seq_id][start:start+l]
                    i += 1
            if len(random_f) != n:
                sys.stderr.write("Not enough sequences of required length")
                return
            else:
                return random_f

        else:
            choice = random.sample(self.ids, n)
            for i in range(n):
                random_f[choice[i]] = self[choice[i]]
        return random_f
230181
def sequenceToWord(sequence):
    
    reberString = ''
    for i in xrange(len(sequence)):
        index = np.where(sequence[i]==1.)[0][0]
        reberString += chars[index]
    return reberString
1053955
def generate(self, pattern=None):
        
        lst = self._lists[pattern]
        while True:
            result = lst[self._randrange(lst.length)]
            # 1. Check that there are no duplicates
            # 2. Check that there are no duplicate prefixes
            # 3. Check max slug length
            n = len(result)
            if (self._ensure_unique and len(set(result)) != n or
                    self._check_prefix and len(set(x[:self._check_prefix] for x in result)) != n or
                    self._max_slug_length and sum(len(x) for x in result) + n - 1 > self._max_slug_length):
                continue
            return result
554092
def fq2fa(fq):
    
    c = cycle([1, 2, 3, 4])
    for line in fq:
        n = next(c)
        if n == 1:
            seq = ['>%s' % (line.strip().split('@', 1)[1])]
        if n == 2:
            seq.append(line.strip())
            yield seq
1107687
def palindrome(seq):
    '''

    '''
    seq_len = len(seq)
    if seq_len % 2 == 0:
        # Sequence has even number of bases, can test non-overlapping seqs
        wing = seq_len / 2
        l_wing = seq[0: wing]
        r_wing = seq[wing:]
        if l_wing == r_wing.reverse_complement():
            return True
        else:
            return False
    else:
        # Sequence has odd number of bases and cannot be a palindrome
        return False
346465
@Override
    public Sequences generate() {
        Sequences seq = new Sequences();

        seq.addVar(new Var("output", this.getProperty("output").value));
        try {
            new ProgramBehaviorGenerator(browser).generateFSMProgramBehaviorClasses(seq);
            new AgentsGenerator(browser).generateAgents(seq);
            new TaskGenerator(getBrowser(), seq).generateAllSeqTasks();
            new ActivityGenerator(getBrowser()).generateTimeIntervals(seq);
            new SymptomEvolutionGenerator(browser).generateFSMSymptomEvolutionClasses(seq);
            new SimulationGenerator(browser).generateSimulations(seq);
            GraphEntity[] entities = browser.getAllEntities();
            Vector<String> errors = new Vector<String>();
            for (GraphEntity norm : entities) {
                Repeat ruleRep = null;
                if (norm.getType().equals("ConsecutiveActions")) {
                    if (norm.getAttributeByName("Deontic") != null
                            && norm.getAttributeByName("Deontic").getSimpleValue().toLowerCase().contains("must not")) {
                        ruleRep = new Repeat("normsmustnot");
                    } else {
                        if (norm.getAttributeByName("Deontic") != null
                                && norm.getAttributeByName("Deontic").getSimpleValue().toLowerCase().contains("must")) {
                            ruleRep = new Repeat("normsmust");
                        } else {
                            ruleRep = new Repeat("normsmay");
                        }
                    }
                    seq.addRepeat(ruleRep);
                    ruleRep.add(new Var("normname", Utils.replaceBadChars(norm.getID())));
                    GraphEntity[] actionconditions = Utils.getRelatedElements(norm, "ActionHappeningAfterwards", "ActionHappeningAfterwardstarget");
                    if (actionconditions.length > 1) {
                        errors.add("There should be only one instance of ActionsHappeningAfterwards connected to " + norm);
                    }

                    if (actionconditions.length == 0) {
                        errors.add("There should one instance of ActionsHappeningAfterwards connected to " + norm);
                    }
                    if (errors.isEmpty()) {
                        GraphEntity[] roleCondition = Utils.getRelatedElements(actionconditions[0], "ActionResponsible", "ActionResponsibletarget");

                        ruleRep.add(new Var("normtimewindow", Utils.replaceBadChars(actionconditions[0].getAttributeByName("WithinTheTimeWindow").getSimpleValue())));
                        ;
                        if (roleCondition.length == 0) {
                            errors.add("There should one instance of Human connected to " + actionconditions[0]);
                        }
                        if (roleCondition.length > 1) {
                            errors.add("There should only one instance of Human connected to " + actionconditions[0]);
                        }
                        if (errors.isEmpty()) {
                            ruleRep.add(new Var("normrolecondition", Utils.replaceBadChars(roleCondition[0].getID())));
                        }

                        GraphEntity[] actionCondition = Utils.getRelatedElements(actionconditions[0], "AffectedAction", "AffectedActiontarget");
                        if (actionCondition.length == 0) {
                            errors.add("There should one instance of Task connected to " + actionconditions[0]);
                        }
                        if (errors.isEmpty()) {
                            for (GraphEntity action : actionCondition) {
                                Repeat normactioncondition = new Repeat("normscondition");
                                ruleRep.add(normactioncondition);
                                normactioncondition.add(new Var("normactioncondition", Utils.replaceBadChars(action.getType())));
                            }
                        }

                        GraphEntity[] deonticAction = Utils.getRelatedElements(norm, "DeonticAssignement", "DeonticAssignementtarget");
                        if (deonticAction.length == 0) {
                            errors.add("There should one instance of Task connected to " + norm);
                        }
                        if (deonticAction.length > 1) {
                            errors.add("There should only one instance of Task connected to " + norm);
                        }
                        if (errors.isEmpty()) {
                            ruleRep.add(new Var("normdeonticaction", Utils.replaceBadChars(deonticAction[0].getType())));
                        }

                        GraphEntity[] normroles = Utils.getRelatedElements(norm, "Role", "Roletarget");
                        if (deonticAction.length == 0) {
                            errors.add("There should one instance of Human connected to " + norm);
                        }
                        if (deonticAction.length > 1) {
                            errors.add("There should only one instance of Human connected to " + norm);
                        }
                        if (errors.isEmpty()) {
                            ruleRep.add(new Var("normrole", Utils.replaceBadChars(normroles[0].getID())));
                        }

                    }
                }
                if (!errors.isEmpty()) {
                    this.fatalError();
                    for (String error : errors) {
                        Log.getInstance().logERROR(error);
                    }
                }
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
        }
        return seq;
    }
49455
function sequence() {
    var funcs = arguments;
    var funcCount = funcs.length;
    return function() {
      var args = arguments;
      for (var i = 0; i < funcCount; i++) {
        args[0] = funcs[i].apply(this, args);
      }
      return args[0];
    };
  }
325315
def iosequence(seq):
        
        lines = Lines()
        lines.add(1, 'cdef public bint _%s_diskflag' % seq.name)
        lines.add(1, 'cdef public str _%s_path' % seq.name)
        lines.add(1, 'cdef FILE *_%s_file' % seq.name)
        lines.add(1, 'cdef public bint _%s_ramflag' % seq.name)
        ctype = 'double' + NDIM2STR[seq.NDIM+1]
        lines.add(1, 'cdef public %s _%s_array' % (ctype, seq.name))
        return lines
189641
public Sequence createSequenceofLength(int length,char base)
	{
		Sequence sequence=new Sequence();
		byte[] sequenceByte=new byte[length];
		for(int i=0;i<length;i++)
		{
			sequenceByte[i]=(byte)base;
	    }
		
		sequence.setSequence(ByteBuffer.wrap(sequenceByte));
	    return sequence;
	}
704501
public static <T, C extends Comparable> FibonacciHeap<T, C> create() {
        return FibonacciHeap.create(Ordering.<C>natural());
    }
729194
function fibonacci(num, memo = {}) {
	if (memo[num]) return memo[num];
	if (num <= 1) return 1;

	return (memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo));
}