By : Jorge Antonio Muñoz
Date : November 23 2020, 03:01 PM

Share :

taking the first type in the list of tuple
By : ron
Date : March 29 2020, 07:55 AM
hop of those help? I had a list l has type: l: list (list (A * B * C * D)) and I would like it returns for me a type list (list A) , I would do it like this: code :
π1 : A × B → A
π1 ∘ π1 : A × B × C → A
π1 ∘ π1 ∘ π1 : A × B × C × D → A
map (π1 ∘ π1 ∘ π1) : (A × B × C × D) * → A *
map (map (π1 ∘ π1 ∘ π1)) : ((A × B × C × D) *) * → (A *) *
Definition comp {s1 s2 s3 : Set} (f2 : s2 > s3) (f1 : s1 > s2) (o1 : s1) : s3 :=
f2 (f1 o1).
Notation "f2 ∘ f1" := (comp f2 f1) (at level 30, right associativity).
Inductive Prod (s1 s2 : Set) : Set :=
 Pair : s1 > s2 > Prod s1 s2.
Arguments Pair {_ _} _ _.
Notation "s1 × s2" := (Prod s1 s2) (at level 40, left associativity).
Notation "( o1 , o2 , .. , o3 )" := (Pair .. (Pair o1 o2) .. o3) (at level 0).
Definition proj_1 {s1 s2 : Set} (p1 : s1 × s2) : s1 :=
match p1 with
 (o1, _) => o1
end.
Notation "'π1'" := proj_1 (at level 0).
Inductive List (s1 : Set) : Set :=
 Nil : List s1
 Cons : s1 > List s1 > List s1.
Arguments Nil {_}.
Arguments Cons {_} _ _.
Notation "s1 *" := (List s1) (at level 30, no associativity).
Notation "'ε'" := Nil (at level 0).
Notation "o1 ◁ l1" := (Cons o1 l1) (at level 60, right associativity).
Fixpoint map {s1 s2 : Set} (f1 : s1 > s2) (l1 : s1 *) : s2 * :=
match l1 with
 ε => ε
 o1 ◁ l2 => (f1 o1) ◁ (map f1 l2)
end.

Taking a list of tuples and returning a tuple
By : user3411678
Date : March 29 2020, 07:55 AM
This might help you here's a recursive version. it performs only one pass along the input list. doing two independent passes often causes space leaks. code :
gather xs = g 0 xs
where
g c [] = (c, [])
g c ((_,ys):r) = (a, ys ++ b)
where
(a,b) = c `seq` g (c+1) r

How to write a vfprintf wrapper that adds a prefix to format specifier and passes the new format specifier to vfprintf i
By : prabhjeet kaur
Date : March 29 2020, 07:55 AM

format specifier inside format specifier to change size of leading zeros
By : yagmurozel
Date : November 27 2020, 12:01 PM

TypeError: list indices must be integers or slices, not tuple when list passed into function
By : Xen626
Date : March 29 2020, 07:55 AM
Any of those help There are many logical and runtime errors in your code. Your best strategy is to convert the list of prices to a NumPy array. NumPy has some very handy functions for solving your problem: code :
import numpy as np
stock_prices = np.array(stock_prices)
def get_max_profit(stock_prices):
high_time = stock_prices.argmax()
low_time = stock_prices.argmin()
if low_time < high_time:
return stock_prices.max()  stock_prices.min()
else:
return 'Negative Balance'



Related Posts :
