Even if thecontestants are divided into teams, they compete as individuals
perhaps this explains hte ego
Even if thecontestants are divided into teams, they compete as individuals
perhaps this explains hte ego
typedef long long ll
what is this in ocaml
Around the mid-19th century, Swiss astronomer Rudolf Wolf rolled a pair of dice 20000 times, recording each outcome.
wtaf
It's like the firing of the neurons is going only in one direction.
is this not what humans do? hebbian plasticity?
i thought that the interesting part of human vs deep learning nets was that NNs went in BOTH directions (backprop + feed forward) whereas humans only went in one direction
can’t train for in advance
francois chollet podcast flashbacks
weird learning disability
lmao
And we can bring common tasks into distribution quite easily through RL and SFT.
some tasks may never enter the distribution; we retain our humanity !! nice
Blind/deaf people
this would be an interesting blog post: on the topic of sample efficiency in humans it seems so odd that they take in dramatically less information, and yet have the cognitive capabilities of those without disabilities
frontier models are terabytes sized
surprising that they are that small honestly
Many billions of years of evolution is our pre-training
argument : pretraining includes all of human evolution rather than just what we learn in our lifetimes.
this is less of something like 'they will eventually be as good as us' or something like that, but more 'its super hard, and its impresive that they have come as far as they have' which is a pessimistic of ML.
unit
interesting
writing a dictionary of type (int × string) to a channel
so what is this doing, it is taking in ch and a dictionary pair, and then it is calling the output string with the channel as a parameger and the int value of k, and then it is prinving a newline, and then it is printing the string of teh other value pair of it, and then it is outputting a newline. so output char takes in ch as its location arguemnt, and takes in /n a char for its other on , while output string does hte same thing, but hmmm how does it know how to update the lcoainot, like how does it konw that it needs otb e at that position in the thing> i guess it woudld mean that the output _(something) funciton always takes hte pointer for the bottom of the page, rather htan anything else, and simply writes underneath it.
and then the dictionary to channel would simply iterate the list of pairs and write it to hte out channel and then output hte unit (which shows that teh function doesnt compute anyhting and return it, it just pastes the text in taht position.
Write a function which rotates a rect such that it is at least as tall as it is wide.
nice
Rewrite the summary paragraph at the end of this chapter for the three argument function g a b c.
let f = fun a -> fun b -> fun c -> something
Why can we not write a function to halve all the elements of a list like this: map (( / ) 2) [10; 20; 30]? Write a suitable division function which can be partially applied in the manner we require.
let div x = fun y -> y / x ;;
and then we do
map (div 2) [list ]
member_all x ls
so it would be something of: a' -> b' list list -> bool and the logic would be to do the double nested loop like you did with the other thing.
Write a function truncate which takes an integer and a list of lists, and returns a list of lists, each of which has been truncated to the given length. If a list is shorter than the given length, it is unchanged. Make use of partial application.
so it is int - > list list -> list list lets just pass take wiht the int value, and sublist, and then pass it for all of them . so it would be let rec truncate a l = match l with h :: t -> take a h :: truncate a l | [] -> [] . .or something like that
type of member x
ermermermermermermermermermemremr i guess that it would be something like list -> bool or something idk. let me think, the whole hting is a' -> b ' list -> bool. so it would be a' -> ( b' list -> bool) and if i am passing the first thing, then it woudl jsut take in the b' list and output a bool
What is its type?
it is a' -> b' list 0-> bool
Write the function union a b which forms the union of two dictionaries. The union of two dictionaries is the dictionary containing all the entries in one or other or both. In the case that a key is contained in both dictionaries, the value in the first should be preferred.
let rec union a b = match a , b with (ka, va) :: ta , (kb, vb) :: tb when ka = kb -> (ka, va) :: union ta tb |ha :: ta , hb :: tb -> ha :: hb :: union ta tb<br /> | or something like that
Write another function which uses the previous one, but handles the exception, and simply returns zero when a suitable integer cannot be found.
yea
Write an exception definition and a function which calculates the largest integer smaller than or equal to the square root of a given integer. If the argument is negative, the exception should be raised.
messy and i dont think i got this good
cycled from zero with square y < x else while greater than zero -> y -1 else raise negative you could also do
Write another function smallest_or_zero which uses the smallest function but if Not_found is raised, returns zero.
done
exception.
done
Write the function for_all which, given a function of type α → bool and an argument list of type α list evaluates to true if and only if the function returns true for every element of the list. Give examples of its use.
let rec forall x y = match y with h :: t -> x h && forall x t | [] -> true ;;
Write a function filter which takes a function of type α → bool and an α list and returns a list of just those elements of the argument list for which the given function returns true.
let rec filter x y = match y with h :: t when x h -> h :: filter x t | h :: t -> filter x t |_-> []
Write a simple recursive function calm to replace exclamation marks in a char list with periods. For example calm [’H’; ’e’; ’l’; ’p’; ’!’; ’ ’; ’F’; ’i’; ’r’; ’e’; ’!’] should evaluate to [’H’; ’e’; ’l’; ’p’; ’.’; ’ ’; ’F’; ’i’; ’r’; ’e’; ’.’]. Now rewrite your function to use map instead of recursion. What are the types of your functions?
this is in curly quotes for some reason. it should be:
['H'; 'e'; 'l'; 'p'; '!'; ' '; 'F'; 'i'; 'r'; 'e'; '!']
and eval to ['H'; 'e'; 'l'; 'p'; '.'; ' '; 'F'; 'i'; 'r'; 'e'; '.']
We mentioned that the comparison functions like < work for many OCaml types. Can you determine, by experimentation, how they work for lists? For example, what is the result of [1; 2] < [2; 3]? What happens when we sort the following list of type char list list? Why?
first to differ + if extended it is greater tha n
We know that take and drop can fail if called with incorrect arguments. Show that this is never the case in msort.
!!!
Combine the sort and insert functions into a single sort function.
nice
Write a function to detect if a list is already in sorted order.
yea this is good h :: g :: t -> h < g && issorted g _-> true
Can you explain why the rev function we defined is inefficient? How does the time it takes to run relate to the size of its argument? Can you write a more efficient version using an accumulating argument? What is its efficiency in terms of time taken and space used?
o(n) i think for normal rev, and
Use your member function to write a function make_set which, given a list, returns a list which contains all the elements of the original list, but has no duplicate elements. For example, make_set [1; 2; 3; 3; 1] might return [2; 3; 1]. What is the type of your function?
honestly embarassing how long this took me jesus
Write a function evens which does the opposite to odds, returning the even numbered elements in a list. For example, evens [2; 4; 2; 4; 2] should return [4; 4]. What is the type of your function?
took me a long time to figure out this was just odds with an offset. just build odds and then call it from evens.
Write a function which, given a list, builds a palindrome from it. A palindrome is a list which equals its own reverse. You can assume the existence of rev and @. Write another function which determines if a list is a palindrome.
yea this was fine. build rev first, and then do list @ rev list
Write a function drop_last which returns all but the last element of a list. If the list is empty, it should return the empty list. So, for example, drop_last [1; 2; 4; 8] should return [1; 2; 4]. What about a tail recursive version?
this was quite tricky.
i think the difficulty is starting to ramp up
Write a function count_true which counts the number of true elements in a list. For example, count_true [true; false; true] should return 2. What is the type of your function? Can you write a tail recursive version?
yup nice one
h is not used in the expression 1 + length t
ahhh its like deconstruction is the reverse of construction.
There is a special pattern x..y to denote continuous ranges of characters, for example ’a’..’z’ will match all lowercase letters. Write functions islower and isupper, each of type char → bool, to decide on the case of a given letter.
i wonder if i need a typecheck or something
What does match 1 + 1 with 2 -> match 2 + 2 with 3 -> 4 | 4 -> 5 evaluate to?
ermmm is it 5
For each of the previous three questions, comment on whether you think it is easier to read the function with or without pattern matching. How might you expect this to change if the functions were much larger?
lowk think it was nicer recursively (or at least more compact) but i guess that it is easier to check cases and conditions
Rewrite the not function from the previous chapter in pattern matching style. Use pattern matching to write a recursive function which, given a positive integer n, returns the sum of all the integers from 1 to n. Use pattern matching to write a function which, given two numbers x and n, computes xn.
nice,
f a matches the pattern 1. If it does, just return 1. If not,
oh so its just more if else statements
Can you suggest a way of preventing the non-termination of the factorial function in the case of a zero or negative argument?
some elseif statements (first check for lessequal zero
Write a function power x n which raises x to the power n. Give its type.
int -> int
Write a function isconsonant which, given a lower-case character in the range ’a’…’z’, determines if it is a consonant.
let isconsonant j = if j = (OR all of the vowels) then false, else true.
Write a recursive function which, given a number n, calculates the sum 1 + 2 + 3 + … + n. What is its type?
i guess that you could also do gauss method for this but it would be a little more finicky. a bit better for time complexity i think
Write a function which returns true if both of its arguments are non-zero, and false otherwise. What is the type of your function?
int -> int -> bool
Write a function which multiplies a given number by ten. What is its type?
int
# let rec gcd a b = if b = 0 then a else gcd b (a mod b);; val gcd : int -> int -> int = <fun> # gcd 64000 3456;; - : int = 128 Here is the evaluation:
holy how did i not think of that
what if we try to evaluate factorial (-1)?
yupyup what is also interesting is that if you put in a superlarge value, it defaults to zero rather than the maxvalue - i wonder why that is?
What is the effect of the comparison operators like < and > on alphabetic values of type char? For example, what does ’p’ < ’q’ evaluate to? What is the effect of the comparison operators on the booleans, true and false?
bool, and counts the position in the alphabet.
true > false and false < true, and true = true = true and false = false = true, i.e things are themselves, are not greater or less than themselves, and true is greater than false and false is smaller than true
Why not just use, for example, the integer 0 to represent false and the integer 1 for true? Why have a separate bool type at all?
perhaps people would get confused between whether something was an int or a bool or sumn idk bro
Can you discover what the mod operator does when one or both of the operands are negative? What about if the first operand is zero? What if the second is zero?
the mod is negative too. if it is (any int) mod (nonzero int) it will always compute, but not if mod operand is 0
What happens when you try to evaluate the expression 1 / 0? Why?
exception: div by zero or whatever that means
The range of numbers available is limited. There are two special numbers: min_int and max_int. What are their values on your computer? What happens when you evaluate the expressions max_int + 1 and min_int - 1?
max is this number 4611686018427387903 and min is htis -4611686018427387904
and it sums to -1
A programmer writes 1+2 * 3+4. What does this evaluate to? What advice would you give him?
11, but in the case that he wanted to make it 21, then he should add parentheses around the expressions he wants to take precedence
Consider the evaluations of the expressions 1 + 2 mod 3, (1 + 2) mod 3, and 1 + (2 mod 3). What can you conclude about the + and mod operators?
that mod takes precedence over add
’%’
-: char = '%' i think
if true then false else true
false
true && false
false
true || false
true
1 <> 1
false
400 > 200
true
800 / 80 / 8
10 / 8
if and then (in our example 100 > 99) must have type bool
BUT what if it didnt :hmmmm
Sometimes, those students with least prior programming experience perform the best.
one can only hope....
some countries persistently have lower defect rates than others on a timescale of decades1,
very cool
But once that company is past the VC-funded hyper growth phase and wants to maximize its profits, it will end up with a multi-thousand person platforms org, just like Google's, unless the company wants to leave hundreds of millions or billions of dollars a year on the table due to hardware and software inefficiency.
hmmmmmm
inimical
learned a nice word today
nd how much that would then change our decisions or actions
this means that it would take into account the importance of the article itself, which doesnt seem right. i could do a criticism of some study also thinking that the outcome of it does not matter - if it was true i would not care, and the same if it was not