71 Matching Annotations
  1. Last 7 days
    1. 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

    1. 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

    2. 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

    3. 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.

    1. 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.

    1. 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

    2. 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 ]

    3. 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.

    4. 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

    5. 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

    1. 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

    1. Write another function which uses the previous one, but handles the exception, and simply returns zero when a suitable integer cannot be found.

      yea

    2. 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

    1. 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 ;;

    2. 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 |_-> []

    3. 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'; '.']

    1. 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

  2. Jun 2026
    1. 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

    2. 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

    3. 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.

    4. 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

    5. 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

    6. 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

    1. 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

    2. 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

    3. 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,

    1. 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

    2. 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.

    3. 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

    4. 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

    5. # 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

    6. 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?

    1. 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

    2. 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

    3. 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

    4. 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

    5. 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

    6. 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

    1. 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

    1. nd how much that would then change our de­ci­sions or ac­tions

      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