~jshholland/trybqn

trybqn/2017.bqn -rw-r--r-- 2.1 KiB
4e81c000Josh Holland use new ⋈ builtin 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Write a function that will return the first n odd natural numbers.
Prob1 ⇐ 1+2×↕ # this seems familiar...

# Write a function that takes an integer array and replaces all the odd
# numbers with the next greater even number.
Prob2 ⇐ 2⊸|⊸+

# Write a function that will remove text found between pairs of double
# quotes (").
Prob3 ⇐ ∨⟜(¬2⊸|∘+`)∘('"'⊸=)⊸/

# Write a function that calculates and returns the areas of 0 or more
# pie slices. The left argument is 0 or more angles (in degrees). The
# right argument is 0 or more pie diameters.
Prob4 ⇐ { 𝕨×𝕩×𝕩×π÷360×4 }

# Write a a function that takes a string representing a nucleotide and
# returns a 1 if it is a valid DNA string, 0 otherwise. In other words,
# are all the characters in the string in the set 'ACGT'?
Prob5 ⇐ ∧´∊⟜"ACGT"

# The term k-mer typically refers to all the possible substrings of
# length k that are contained in a string. In computational genomics,
# k-mers refer to all the possible subsequences (of length k) from a read
# obtained through DNA Sequencing. Write a dfn that takes a character
# vector as its right argument and k (the substring length) as its left
# argument and returns a vector of the k-mers of the original string.
Prob6 ⇐ <˘↕⎊⟨⟩

# Write a function that takes a character vector representing a DNA
# string and returns 4 integers of the number of occurrences for each
# of the symbols ‘A’, ‘C’, ‘G’, and ‘T’ respectively.
Prob7 ⇐ 4⊸↑·/⁼∘∧"ACGT"⊸⊐

# Write a dfn that takes a Boolean vector or scalar and “turns off”
# all the 1s after the first 1.
Prob8 ⇐ ∊⊸∧

# Write a function that takes a character vector or scalar and returns
# a Boolean vector indicating anywhere an element is followed by an
# element of the same value.
Prob9 ⇐ «⊸=

# Write a function that will reshape a given array into the smallest
# square matrix that will contain all the elements of the argument,
# padding with additional elements if necessary.
Prob10 ⇐ ∾˜∘⌈∘√∘≠⥊⌈⌾√∘≠⊸↑